Image Cropping

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Image Cropping

Post by yogi108 » 28 Mar 2020 14:51

Hi there,

I want to crop an image and save the result.

Just found out about
start action

Code: Select all


Action:
android.intent.action.VIEW

Data URI
file:///storage/.....

MIME Type
image/*

Explicite Component
com.android.gallery3d

class name
com.huawei.gallery.app.CropImageActivity

That's pretty cool, but it doesn't save the cropped area, only showing the area and you can play around the size.

Anyway, if I use that it is HUAWEI, even if I get it somehow to work it is not compatible with others.
Any idea?

Regards
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Image Cropping

Post by Desmanto » 28 Mar 2020 17:25

You don't need external app to do this. Automagic has action modify image. Use action init variable image file first, you can retrieve the path using pick file from your previous thread. Init the image, do modify image - crop to selection. The save the image again as file, then share it using Start Activity (if needed).
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Re: Image Cropping

Post by yogi108 » 28 Mar 2020 17:52

Hi Desmanto,

Thanks for your input.
Doing like you described there is the need to know the size of cropping.
I want a file to be shown, interactive move the points of
an rectangle and crop it. Is this really possible with AM
on board action? Did I miss something?

Thanks a lot
Regards
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Re: Image Cropping

Post by yogi108 » 02 Apr 2020 05:51

Hi,
I could still not find a way to crop an image visual in AM.
If I could get 4 points visual I could crop it with AM.
any hints?
Regards
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Image Cropping

Post by Desmanto » 02 Apr 2020 06:17

Not yet, Automagic doesn't have interactive cropping/resizing. It is for automation, so I don't think it will implement it. You should share to external app then, cropped there. I use picsay, but you can use other app too.

There is a way though to do it from Automagic alone. But the cropped area won't have exact pixel accuracy. Use Widget to show the image almost full screen. Let say the picture is 3000x4000. Then after the show widget action, use Show Control UI Gesture Recorder. This will show you the record screen. Draw a diagonal line from the top left to the bottom right of the picture. OK, then close the gesture recorder. The flow continue on to retrieve the coordinate from the recorded gesture. Calculate the top left and bottom right coordinate. Scale the pixel percentage to the screen resolution and get the exact x,y for the image resolution. Then calculate the width and height based on the bottom right coordinate. Load the image and crop based on these data, save it again.

There are also way you can predefined x,y to crop/scale to certain size and see the approximate result semi-realtime, by overlaying additional rectangle on the widget.

Seems too troublesome and might not be accurate (if you need accuracy). You better use 3rd party app to do it, maybe "resize me".
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Re: Image Cropping

Post by yogi108 » 02 Apr 2020 08:01

Desmanto wrote:
02 Apr 2020 06:17
Not yet, Automagic doesn't have interactive cropping/resizing. It is for automation, so I don't think it will implement it. You should share to external app then, cropped there. I use picsay, but you can use other app too.

There is a way though to do it from Automagic alone. But the cropped area won't have exact pixel accuracy. Use Widget to show the image almost full screen. Let say the picture is 3000x4000. Then after the show widget action, use Show Control UI Gesture Recorder. This will show you the record screen. Draw a diagonal line from the top left to the bottom right of the picture. OK, then close the gesture recorder. The flow continue on to retrieve the coordinate from the recorded gesture. Calculate the top left and bottom right coordinate. Scale the pixel percentage to the screen resolution and get the exact x,y for the image resolution. Then calculate the width and height based on the bottom right coordinate. Load the image and crop based on these data, save it again.

There are also way you can predefined x,y to crop/scale to certain size and see the approximate result semi-realtime, by overlaying additional rectangle on the widget.

Seems too troublesome and might not be accurate (if you need accuracy). You better use 3rd party app to do it, maybe "resize me".
Hi Desmanto,
I like cool ideas, it seems this solution needs much attention, maybe I'll give it a try later.
Just found out Resize me pro they just offer it for free THIS day, if anyone looks out for it.

Beside this theme is there any way to find out when starting an intent which extras there are to use
and which variables getting back? Of course it differs from app to app...

Using already "catch intent" if sharing to see what kind of data the app provides, but this is the other side...

Thanks a lot,
Regards
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

BoBo
Posts: 129
Joined: 05 May 2014 12:45

Re: Image Cropping

Post by BoBo » 02 Apr 2020 10:17

Thx for the hint regarding (the momentarily free of charge) Resize Me Pro app:
https://play.google.com/store/apps/deta ... size&hl=en

:)

@ all
are there Android Apps out there which provide "command line" accessibility of its core functionalities ??

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Image Cropping

Post by Desmanto » 03 Apr 2020 02:06

@yogi108 : I am trying to proof my concept using widget alone, need some time. Resize me pro for free is just pure coincidence :D You need to enable edit image from other app in the setting, in order to to crop manually after opening from Automagic.

Finding the "extra" passed is one of the challenge. I usually use intent intercept (can be downloaded from F-Droid, if you can't find it in playstore), if the app have the export/share intent or receive it. But if the activity is started background, you can take a peek of its action using logcat. Which I have done using my logcat flow, filter for ActivityManager. However, we still can't see the extra, which I am still trying to find the way. So far, unless the dev provide the documentation for it, it is quite difficult to know the detail. You can decompile the apk, but it is very difficult to search for it.


@BoBo : Most don't. If they open up, usually thru broadcast or activity, not from command line. Have to ask the dev for it. Usually they will provide a good documentation if they have decided to open up their function.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
yogi108
Posts: 100
Joined: 09 Nov 2016 08:00
Contact:

Re: Image Cropping

Post by yogi108 » 03 Apr 2020 04:46

Desmanto wrote:
03 Apr 2020 02:06
@yogi108 : I am trying to proof my concept using widget alone, need some time. Resize me pro for free is just pure coincidence :D You need to enable edit image from other app in the setting, in order to to crop manually after opening from Automagic.

Finding the "extra" passed is one of the challenge. I usually use intent intercept (can be downloaded from F-Droid, if you can't find it in playstore), if the app have the export/share intent or receive it. But if the activity is started background, you can take a peek of its action using logcat. Which I have done using my logcat flow, filter for ActivityManager. However, we still can't see the extra, which I am still trying to find the way. So far, unless the dev provide the documentation for it, it is quite difficult to know the detail. You can decompile the apk, but it is very difficult to search for it.


@BoBo : Most don't. If they open up, usually thru broadcast or activity, not from command line. Have to ask the dev for it. Usually they will provide a good documentation if they have decided to open up their function.
Found the setting and it works, at the moment this is the simplest way for me for cropping and I will use it in the flow next time.

Regarding the intent it should be a simple way - you know if you look at the source a few month later, even if you give some info and documentation
you need some time to come again to the point ....

Thanks again :-)
Regards
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga

Post Reply