FREE crop image code

Hello everyone, this is my first post, and I would like to share with you this code in blocks for the crop of images I hope it is very useful, if someone is encouraged to make a donation, I would be very grateful.

Dramon

14 Likes

nice

1 Like

adding several ExtraValue blocks results in overwriting, so only the last one will make it in the end…
Unbenannt

also the ExtraValue block is deprecated… you might want to use the Extras block instead, see an example here how to use it App Inventor Code Snippets | Pura Vida Apps

and btw. the image extension also offers a free Crop method…

Taifun

2 Likes

Nice, Nice

This is impressive.

EDIT: The Extras do not change anything. I might be wrong…

Here are the changes @Taifun proposed


Here are the texts for copy and paste

com.android.camera.action.CROP
image/*
android.intent.category.DEFAULT
"crop","true"
"return-data",true
"aspectX",100
"aspectY",100
"outputX",255
"outputY",255

Excelent, bro

you might want to try to remove the Extras block completely… probably it’s not required at all?

another thing to try is
Unbenannt
Taifun

I actually tried this, but without the “” and it didn’t work

Nice. Now, with an AIA to make the life easier:sunglasses::sunglasses:
Crop_Source.aia (2.8 KB)

7 Likes

Can’t we do anything so it only crops square image. BTW this was nice :+1:

Does this work for anyone in apk? It works in Live Testing, but when I export apk, it throws error "java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content [...] requires android.permission.READ_EXTERNAL_STORAGE". Any idea on how to get this permission?

Have you accepted the permissions in the app settings?

My app seems to not request them. Only camera access can be granted. The strange thing is that my FileAlt extension should request that…

PS: Here is the line of code in my extension that should request this permission

add for example the file component to your project
Taifun

I’ve tried it on several phones with different versions and it works very well with exception of:

‘aspectX’, 100
‘aspectY’, 100
‘outputX’, 255
‘outputY’, 255

1 Like

I tried @Dramon_Reyes’ code and these three lists as inputs to ActivityStarter.Extras, but none of them work.


If anybody has been successful in implementing a square crop method with the ActivityStarter, please let me know

the example project by @fabioirmao worked fine for me on Nexus 5x running on Android 8.1 using the companion app
Taifun

The ratio isn’t fixed on my Moto E (1st Gen) running Android 5.1 nor my Moto G (3rd Gen) running Android 6.0.1

1 Like

Thank you ^^. It helps me a loooooot~~ :heart_eyes: