Set Image output from extension

Hello all
This is my new extension.
Description

This extension allow you to edit image files and obtain a new image file
I did it because when i wanted to dark an image and blur it befor to set it in layer
I have only found 3 simples extensions :

but edited image was not save in file and was not really background image
so th only way was to use

the probem was it spend lot of time And i didn't succed to do it asynchronous with

With this extension, you can edit image file and get it as an image file
you can also scale it to reduce it and go faster
you can do several editions and get result in a file
You can do all this async in order to not freeze your app

Thanks to Justus Raju because i started with his extension
https://mit-cml.github.io/extensions/data/extensions/ai.cdk.justus.ImageProcessor.aix
I corrected some little bugs and completed it, many thanks

I hope it will be helpful for some of you

Properties

component_set_get
Define file path where you 'll find modified image
/ImgChanged/tmp.png by default

component_set_get
Define path where is image to Edit
can be a path or Assets image

component_set_get
give you file path of modified image

Methods

image
image
Blurd image define by filPath
radius must be < 2*min (height, width) -1

image
image
Blurd image define by filPath only by column
radius must be < 2*height -1

image
image
Blurd image define by filePath only by row
radius must be < 2*width -1

image
Check if mp3 file contains an image

component_method
image
Change brithness of image
0<valeur<1
if 0<valeur<0,5 dark image
If 0,5<valeur<1 claire image

image
image
Add a color on image
0<weight<1 if weight=1 only image, iff weight=1 only color

image
image

component_method
imageimage

create a combined image from imageA and imgaeB

Grey image

image
return image height

image
return image width

image
Scale image to define width and height

image
Scale Image to change width and height according to ratio
0<ratio<1
.
.
.
All subsequent blocks do same as previus but on Image seted with « SetImagePath »
you can set several editions without load and save image for each edition
This will save proccessing time
Then you will obtain edited image with « Get ImagePath »

image
image
image
component_method
image
component_method
image
image
image
.
.
component_method
with this block you can set an image from mp3 file to edit it

jml.EditImage.aix (22,1 Ko)

ImageEditor.aia (78,9 Ko)

EditImage.txt (30,4 Ko)

2 Likes

Is this a finished extension or do you need help with it?

I ask because you have not posted this in the Extensions category?

Please follow the naming conventions

And fix the spelling errors.
valeur --> value
weigh --> weight

Taifun
PS: moved into the correct category and unlisted meanwhile

property names no need start with set or get.

yes you can help me:
i 'd like to use AI loaded image image but i don't succed to get it in my code:

    @DesignerProperty()
    @SimpleProperty(description = "Sets the Image ")
    public void SetImage(Bitmap bitmap) {
        this.globalBitmap = bitmap;
    }
	*/

this give me an error:
java.lang.IllegalArgumentException: Cannot convert Java type 'android.graphics.Color' to Yail type

i tried this


but mx.gif is just a string so i don't know how to put this image in "this.globalBitmap"

Sorry,
i'm not relly familiar..i corrected it in my irst post aix...
i'll change in aia when all will be rigth...

ok. now i updated aix, aia and source according to your remarks...

somebody could help me with this ?

what's this meaning?

image
image

and then i want to use it in my extension
I rtrid this:

 @DesignerProperty()
    @SimpleProperty(description = "Sets the Image ")
    public void SetImage(Bitmap bitmap) {
        this.globalBitmap = bitmap;
    }
	*/

it it's not an Bitmap it seems to be a String "mx.gif" ...
I don't know how to do to get it in Bitmap to edit it...

public void SetImage(String filePath) {
    Bitmap bitmap = BitmapFactory.decodeFile(filePath);

well...
i tried this

    @DesignerProperty()
    @SimpleProperty(description = "Sets the Image ")
    public void Image(String image) {
		this.globalBitmap = BitmapFactory.decodeFile(image);
		this.globalBitmapSet=true;
    }
	@DesignerProperty()
    @SimpleProperty(description = "")
	public String test(){
		if(this.globalBitmap!=null)return "ok";
		else return "null";
	}

but it return null.......

You have to write the "bitmap" back out to file once you have "modified" it.

final FileOutputStream stream = new FileOutputStream(output,false)) {
        //modify bitmap here
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, (OutputStream) stream);
        stream.close();

        File file = new File(output); //new filename with path

Yes of course ! i have already a procedure like this,
but i wrote this

@DesignerProperty()
    @SimpleProperty(description = "")
	public String test(){
		if(this.globalBitmap!=null)return "ok";
		else return "null";
	}

because after

 @DesignerProperty()
    @SimpleProperty(description = "Sets the Image ")
    public void Image(String image) {
		this.globalBitmap = BitmapFactory.decodeFile(image);
		this.globalBitmapSet=true;
    }

when i try to modify this.globalBitmap i get an error " attempt to invoke virtual methode 'int android.graphics.Bitmap.getWidth() on a null reference object reference"...
it seems there is nothing in this.globalBitmap

This should work in the compiled APK. If you are testing in companion you must use decodeFile. But you need to get the full path to the file, because the gif file block in app inventor returns only the file name, without the path.

@DesignerProperty()
    @SimpleProperty(description = "Sets the Image ")
    public void Image(String image) {
        AssetManager assetManager = context.getAssets();
        InputStream inputStream = assetManager.open(image);
		this.globalBitmap = BitmapFactory.decodeStream(inputStream);
		this.globalBitmapSet=true;
    }
	@DesignerProperty()
    @SimpleProperty(description = "")
	public String test(){
		if(this.globalBitmap!=null)return "ok";
		else return "null";
	}

and bitmapfactory only works with JPEG/PNG/WEBP.

yes i use compile APK but it doesn't works...

that is my problem: how can i find full path ?
i can't see any file "mx.gig" with my file explorer...

Have you tried this code? Try the same code but with a PNG file, as Tim mentioned.

it seems i must import class, but i dont know which one,
i tried import android.AssetManager; but no success...sorry, i'm newbee