[Free] Image Convertor: extension to convert image format jpg / png / webp (and much much more)

How about just trying it out?
And then let us know.

1 Like

Extension Remix and Update

  • fixed file paths to allow for ASD
  • added quality option to the block (works for jpg and webp, png is lossless) scale of 0 -100, 100 gives best visual appearance.
  • Coded to handle deprecation of WEBP, which is replaced with WEBP_LOSSY from API 30. Devices on less than 30 will use WEBP, those above WEBP_LOSSY
  • error handling and error messaging improved

For clarity, extension converts between jpg, png and webp file formats (these are the only ones available for Bitmap.CompressFormat) or you can reduce quality / filesize of existing file format. Files to be converted must have a valid extension (e.g. file1.jpg / file2.png / file3.webp)

Image Convertor

image

Credits @Kumaraswamy for original extension.

#####################################################################
This work by TIMAI2 is licensed under an
MIT Licence
#####################################################################

5 Likes

2022-05-18

Update to remixed extension, now adds a resize function.

component_method

Description:

Resizes an image file, with format: jpg,png,webp.

A single size is required (will adjust to the longest side), and aspect ratio will be retained.

Important! use the same extension for target and output.

Use the same path for target and output if you want to overwrite the target file - this is irreversible.

2022-09-02

Updated again to V8. The extension now uses events to return the output file path, and file sizes for the new file (formatted and in bytes) and target file (in bytes)

2023-07-11

Updated again now to V2.10. Included are Rotate and SetOpacity methods.

image

image

SetOpacity will only work with png and webp sources.

2023-07-27

Updated again to V2.11. Revised code for Opacity.

Thanks @Martin_Herraiz & @Juan_Antonio for encouragement and advice

2024-05-12

Updated to V.32. Now includes a crop function, image dimensions, thumbnail, and handles file paths better.

image

Extension:
Image Convertor

Credits @Kumaraswamy for original extension.
Credits to Asad Ali Choudhry for their resize and keep aspect java code

#####################################################################
This work by TIMAI2 is licensed under an
MIT Licence
#####################################################################

3 Likes

Hello. Thanks for this image converter extension.
I would like to convert a jpg image to a png image, but control the overall transparency/opacity of the png file (same transparency for all the image).
Is this functionality available in an other extension (I searched without success), or would it be possible to add a parameter: percentage of transparency (value of alpha channel) to the convert block?
Thank you very much

New version created to include Rotate and SetOpacity methods.
Please download from the same url as above.
[ImageConvertor V2.11]

1 Like

Hi Tim
Thanks you very much for your very quick feedback and for adding this feature to your extension. I really appreciate
I am now trying to use your extension, but I am facing some issues:

  • I did not find the documention of the extension, and on the parameters. e.g. I assume the quality is between 1 and 100 (100: best quality): Is it true
  • I try to convert a JEPEG photo taken from the standard camera stored in /DCIM/Camera/ and convert it to a png file in App folder, but it fails. here are my blocks and the test result of these blocks

I am sure I am missing something, but unable to find it. Could you give me some tip?

Thanks

What android version are you testing with ?

Version 11 RKQ1 on a Xiaomi Mi11 Ultra
DefaultFileScope is set to Legacy (Thanks to Anke information), and it does not look like a permission issue

Any reason for setting the filescope to Legacy, other than for this activity ?

Works fine with filescope set to App (tested with companion app on android 13 device)

(This for a camera image taken by the device camera component, not from within the app)

Thanks a lot, it works fine. I use ASD for the destination, so it works for both the companion and the installed APP

1 Like

I now also checked resize and opacity: BOTH works fine
Thank you very much

1 Like

Attached is my test Application: ImageConvertor. Hope it will ease your extension usage.

ImageConvertor.aia (50.2 KB)

Kind Regards

Jacques

1 Like

Dear TIMAI2
While using your ImageConvertor, can we zoom in / zoom out with finger tips?
Regards

This extension does not provide a zoom function. Search to community for other methods and extensions that may do this

Hi Tim,

Actually, it looks like changing the opacity with SetOpacity change the dynamic of the image, but do not change the alpha channel of the image.

If I have a canvas with a background color e.g. green and I set a background image witch is 50% transparent (ispahan-50.png), I get a mix of the green and the image.

If I start from a JPEG and change the opacity with the SetOpacity block and display it over the green background, the image is darker, but is not greenish: mixed with the green background.

Here is my test app: TestTransparency.aia (1.7 MB)

Any idea what is going wrong?

Thanks

Looks OK to me....

(The green colour is actually more vibrant on the device screen)

I did try this with one of my own photos - @ 4mb, and yes it does darken. Will see if I can find out what is going on.

Yes, it is OK with the test image, but not when generated with SetOpacity block.

It works OK if you use webp instead of png. You can output your image from the canvas to png though.
Still testing....seems to be OK for images that are already a png (so no need to convert image type)

@Jacques_Dumarest Hopefully fixed it. Try this new version of the extension:

uk.co.metricrat.imageconvertorV2.11.aix (12.5 KB)

Thanks for this V2.11
I tried it


but it still does not work :frowning:

I also tried webp format, and it also fails.

Here is my App: TestTransparency.aia (1.7 MB)