با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
WebP یک فرمت فایل تصویری از Google است که فشردهسازی با اتلاف (مانند JPEG) و همچنین شفافیت (مانند PNG) را ارائه میکند، اما میتواند فشردهسازی بهتری نسبت به JPEG یا PNG ارائه دهد. تصاویر Lossy WebP در اندروید 4.0 (سطح API 14) و بالاتر و تصاویر WebP بدون ضرر و شفاف در اندروید 4.3 (سطح API 18) و بالاتر پشتیبانی می شوند. این صفحه نحوه تبدیل تصاویر به فرمت WebP و نحوه تبدیل تصاویر WebP به فرمت PNG را نشان می دهد.
برای اطلاعات بیشتر در مورد انتخاب فرمت تصویر صحیح برای بهبود سرعت دانلود، به کاهش اندازه دانلود تصویر مراجعه کنید.
تبدیل تصاویر به WebP
Android Studio می تواند تصاویر PNG، JPG، BMP یا GIF استاتیک را به فرمت WebP تبدیل کند. شما می توانید تصاویر جداگانه یا پوشه های تصاویر را تبدیل کنید.
برای تبدیل یک تصویر یا پوشه از تصاویر، به صورت زیر عمل کنید:
روی یک فایل تصویری یا پوشه حاوی فایل های تصویری کلیک راست کرده و سپس روی Convert to WebP کلیک کنید.
گفتگوی تبدیل تصاویر به WebP باز می شود. تنظیمات پیشفرض به تنظیمات minSdkVersion برای ماژول فعلی بستگی دارد.
شکل 1. گفتگوی تبدیل تصاویر به WebP.
رمزگذاری با اتلاف یا بدون اتلاف را انتخاب کنید.
رمزگذاری بدون اتلاف تنها در صورتی در دسترس است که minSdkVersion شما روی 18 یا بالاتر تنظیم شده باشد.
اگر رمزگذاری با اتلاف را انتخاب میکنید، کیفیت رمزگذاری را تنظیم کنید و انتخاب کنید که آیا پیشنمایش هر تصویر تبدیلشده قبل از ذخیرهسازی انجام شود یا خیر.
همچنین میتوانید از تبدیل هر فایلی که نسخه کدگذاریشده بزرگتر از نسخه اصلی یا هر فایلی با شفافیت یا کانال آلفا باشد، صرفنظر کنید. از آنجایی که Android Studio فقط به شما امکان میدهد تصاویر شفاف WebP را در صورتی ایجاد کنید که minSdkVersion شما روی 18 یا بالاتر تنظیم شده باشد، اگر minSdkVersion شما کمتر از 18 باشد، چک باکس Skip images with transparency/alpha channel به طور خودکار انتخاب میشود.
توجه: فایل های 9 پچ را نمی توان به تصاویر WebP تبدیل کرد. ابزار مبدل همیشه به طور خودکار تصاویر 9 پچ را رد می کند.
برای شروع تبدیل روی OK کلیک کنید.
اگر بیش از یک تصویر را تبدیل میکنید، تبدیل یک مرحله است و میتوان آن را واگرد کرد تا همه تصاویری که تبدیل کردهاید به یکباره بازگردانده شوند.
اگر تبدیل بدون ضرر را انتخاب کرده باشید، تبدیل بلافاصله انجام می شود. تصاویر شما در مکان اصلی خود تبدیل می شوند. اگر تبدیل با ضرر را انتخاب کرده اید، به مرحله بعد ادامه دهید.
اگر تبدیل با ضرر را انتخاب کردهاید و پیشنمایش هر تصویر تبدیلشده را قبل از ذخیره کردن انتخاب کردهاید، Android Studio هر تصویر را در طول تبدیل به شما نشان میدهد تا بتوانید نتیجه تبدیل را بررسی کنید. در مرحله پیش نمایش، می توانید تنظیمات کیفیت را برای هر تصویر به صورت جداگانه تنظیم کنید، همانطور که در شکل 2 نشان داده شده است.
اگر پیش نمایش تصاویر تبدیل شده را انتخاب نکردید، Android Studio از این مرحله صرف نظر می کند و بلافاصله تصاویر شما را تبدیل می کند.
شکل 2. پیش نمایش تبدیل یک تصویر JPG به فرمت WebP با کیفیت 75 درصد.
شکل 2 تصویر اصلی JPG را در سمت چپ و تصویر WebP کدگذاری شده با اتلاف را در سمت راست نشان می دهد. دیالوگ اندازه فایل اصلی و تصویر تبدیل شده را نشان می دهد. می توانید نوار لغزنده را به چپ یا راست بکشید تا تنظیمات کیفیت را تغییر دهید و فوراً تأثیر آن را روی تصویر رمزگذاری شده و اندازه فایل مشاهده کنید.
ناحیه وسط پیکسل هایی را نشان می دهد که بین تصویر اصلی و تصویر کدگذاری شده تفاوت دارند. در شکل 2، با تنظیم کیفیت روی 75 درصد، تقریباً هیچ تفاوتی بین این دو تصویر وجود ندارد. شکل 3 همان تصویر را نشان می دهد که با کیفیت 0% کدگذاری شده است.
شکل 3. پیش نمایش تبدیل یک تصویر JPG به فرمت WebP با کیفیت 0٪.
توجه: اگر کیفیت را روی 100٪ تنظیم کنید و minSdkVersion را روی 18 یا بالاتر تنظیم کنید، Android Studio به طور خودکار به جای آن به رمزگذاری بدون اتلاف تغییر می کند.
برای هر تصویری که مرور می کنید، یک تنظیم کیفیت انتخاب کنید. اگر بیش از یک تصویر را تبدیل می کنید، روی Next کلیک کنید تا به تصویر بعدی بروید.
روی Finish کلیک کنید. تصاویر شما در مکان اصلی خود تبدیل می شوند.
تبدیل تصاویر WebP به PNG
اگر می خواهید از یک تصویر WebP از پروژه خود برای هدف دیگری استفاده کنید - به عنوان مثال، در یک صفحه وب که نیاز به نمایش صحیح تصاویر در یک مرورگر بدون پشتیبانی WebP دارد، می توانید از Android Studio برای تبدیل تصاویر WebP به فرمت PNG استفاده کنید.
برای تبدیل یک تصویر WebP به PNG به صورت زیر عمل کنید:
روی یک تصویر WebP در Android Studio کلیک راست کنید و سپس روی Convert to PNG کلیک کنید.
یک گفتگو ظاهر می شود که از شما می پرسد آیا می خواهید فایل اصلی WebP را پس از تبدیل حذف کنید یا فایل اصلی WebP و همچنین فایل PNG جدید را حفظ کنید.
برای حذف فایل WebP اصلی بر روی Yes کلیک کنید یا برای حفظ فایل WebP علاوه بر فایل PNG، خیر . تصویر شما بلافاصله تبدیل می شود.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Create WebP images\n\n[WebP](https://developers.google.com/speed/webp/) is an image file format from\nGoogle that provides lossy compression (like JPEG) as well as transparency (like\nPNG) but can provide better compression than either JPEG or PNG. Lossy WebP\nimages are supported in Android 4.0 (API level 14) and higher, and lossless and\ntransparent WebP images are supported in Android 4.3 (API level 18) and higher.\nThis page shows how to convert images to WebP format and how to convert WebP\nimages to PNG format.\n| **Note:** Because support for lossless and transparent WebP images is only available in Android 4.3 and higher, your project must declare a `minSdkVersion` of 18 or higher to create lossless or transparent WebP images using Android Studio.\n\nFor more information about\nselecting the correct image format to improve download speed, see [Reduce image\ndownload sizes](/topic/performance/network-xfer#webp).\n\nConvert images to WebP\n----------------------\n\nAndroid Studio can convert PNG, JPG, BMP, or static GIF images to WebP format.\nYou can convert individual images or folders of images.\n\nTo convert an image or folder of images, proceed as follows:\n\n1. Right-click an image file or a folder containing image files, and then click **Convert to WebP**.\n2. The **Converting Images to WebP** dialog opens. The default settings\n depend on the `minSdkVersion` setting for the current module.\n\n \u003cbr /\u003e\n\n **Figure 1.** The Converting Images to WebP dialog.\n3.\n Select either lossy or lossless encoding.\n\n Lossless encoding is only available if your `minSdkVersion` is set to 18 or higher.\n\n If you select lossy encoding, set the encoding quality and choose whether\n to preview each converted image before saving.\n\n\n You can also choose to skip the conversion of any files where the encoded\n version would be larger than the original or any files with transparency\n or an alpha channel. Because Android Studio only lets you\n create transparent WebP images if your `minSdkVersion` is set\n to 18 or higher, the **Skip images with transparency/alpha channel**\n checkbox is automatically selected if your `minSdkVersion`\n is lower than 18.\n\n\n **Note:** 9-patch files can't be converted to WebP images. The\n converter tool always automatically skips 9-patch images.\n4. Click **OK** to begin the conversion.\n\n If you are converting more than\n one image, the conversion is a single step, and can be undone to revert all\n the images you converted at once.\n\n If you selected lossless conversion, the conversion happens\n immediately. Your images are converted in their original\n location. If you selected lossy conversion, continue to the next step.\n5.\n If you selected lossy conversion and you chose to\n preview each converted image before saving, Android Studio\n shows you each image during the conversion so you can inspect the\n conversion result. During\n the preview step, you can adjust the quality setting for each image\n individually, as shown in figure 2.\n\n If you did not choose to preview the converted images, Android\n Studio skips this step and converts your images immediately.\n **Figure 2.** Previewing the conversion of a JPG image to WebP format at 75% quality.\n\n\n Figure 2 shows the original JPG image on the left and the lossy-encoded\n WebP image on the right. The dialog shows the file size for the original\n and the converted image. You can drag the slider left or right\n to change the quality setting and immediately see the effect on the\n encoded image and the file size.\n\n\n The middle area shows the pixels that differ between the original image\n and the encoded image. In figure 2, with the quality set to 75%, there's\n almost no difference between the two images. Figure 3 shows the same image\n encoded with the quality set to 0%.\n **Figure 3.** Previewing the conversion of a JPG image to WebP format at 0% quality.\n\n **Note:** If you set the quality to 100% and the\n `minSdkVersion` is set to 18 or higher, Android Studio\n automatically switches to lossless encoding instead.\n\n Select a quality setting for each image you review. If you are converting\n more than one image, click **Next** to advance to the next image.\n6. Click **Finish**. Your images are converted in their original location.\n\nConvert WebP images to PNG\n--------------------------\n\nIf you want to use a WebP image from your project for another purpose---for\nexample, in a web page that needs to correctly display images in a browser\nwithout WebP support---you can use Android Studio to convert WebP images to PNG\nformat.\n\nTo convert a WebP image to PNG, proceed as follows:\n\n1. Right-click a WebP image in Android Studio, and then click **Convert to\n PNG**.\n2. A dialog appears, asking whether you would like to\n delete the original WebP file after conversion or keep the original WebP\n file as well as the new PNG file.\n\n Click **Yes** to delete the original WebP file or **No**\n to retain the WebP file in addition to the PNG file. Your image is converted\n immediately."]]