Cant get Scale_Image to work

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
RocketRod
Posts: 907
Joined: Wed Aug 06, 2008 4:22 am
Location: Melbourne

Cant get Scale_Image to work

Post by RocketRod »

Any tricks to this?

BO.Picture is a Picture attribute

Tried BO.Picture=Scale_IMage(BO.Picture,50)

Also BO.Picture=Scale_Image(BO.Picture,600,600)

Get in log value not changed because it was equal to the old value Picture=null

What am I doing wrong?

Cheers ROd
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

I've tried to reproduce this:

My Rule:
  • If Object.Picture IS DEFINED
    Then Object.Picture=SCALE_IMAGE(Object.Picture,500,500)
I can tell you that the picture is uploaded, scaled to 500,500 and displayed on the form properly. There are some questionable things in the log.
  • + Evaluating rule 'Picture' If Object.Picture IS DEFINED Then Object.Picture=SCALE_IMAGE(Object.Picture,500,500)
    - Evaluating condition Object.Picture IS DEFINED
    - Condition evaluated to true: null
    - Adding action Object.Picture=SCALE_IMAGE(Object.Picture,500,500) to the agenda

    + Executing action Object.Picture=SCALE_IMAGE(Object.Picture,500,500) from rules of object Object
The log also shows the combination of the two actions below executed another 31 times afterwards:
  • * Started evaluation of rules after data has been changed by the actions
    * Executing action Object.Picture=SCALE_IMAGE(Object.Picture,500,500) from rules of object Object
Cheers
RocketRod
Posts: 907
Joined: Wed Aug 06, 2008 4:22 am
Location: Melbourne

Post by RocketRod »

Thanks Rennur.

Picture uploads and display fine. But still can't get it to resize. Must be the message in the log Picture =null?

Don't know what else to try.

Is it a bug support?

Cheers Rod

Using 1717
aware_support
Posts: 7567
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

It should work as Rennur says. What's in your log?
Aware IM Support Team
RocketRod
Posts: 907
Joined: Wed Aug 06, 2008 4:22 am
Location: Melbourne

Post by RocketRod »

Executing action PictureItem.Picture=SCALE_IMAGE(PictureItem.Picture,50) from rules of object PictureItem
Value was not changed because it was equal to the old value Picture=null

Cheers Rod
aware_support
Posts: 7567
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Can you try SCALE_IMAGE(PictureItem.Picture, 50, 50)?
Aware IM Support Team
RocketRod
Posts: 907
Joined: Wed Aug 06, 2008 4:22 am
Location: Melbourne

Post by RocketRod »

Well they did work in a sense in that it rescaled the picture. However using the height and width functions it shows me that the height and width are both now set to 2500 which is 50*50. I would have thought they should be 50?
Maybe the height and width functions also have an issue? At least I can't get the scale image to work with a percentage.


Anyway totally confused now.


Cheers Rod
aware_support
Posts: 7567
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Actually, if the function has two parameters the second parameter indicates scale as a number between 0 and 1 (for 50% use 0.5)

If there are 3 parameters the second and third parameters are width and height of the result in pixels. The documentation of the function is misleading
Aware IM Support Team
RocketRod
Posts: 907
Joined: Wed Aug 06, 2008 4:22 am
Location: Melbourne

Post by RocketRod »

THANKS!

All worked now. Anyone wanting to use it take note of the above.

Wish List - As I posted elsewhere would be great to have the resize done BEFORE the upload to save time.

Cheers Rod
Gabbitas
Posts: 334
Joined: Sun Jan 03, 2010 3:36 am

Re: Cant get Scale_Image to work

Post by Gabbitas »

Hi,

Just wanted to bring some of this one to the forefront again. As mentioned a few times in the past it would be good to have an image scaled before it gets uploaded especially from mobile devices. Some phones now have very hi res cameras built in and produce quite large image file size. I have users tring to upload pictures 5 or even 10mb in size. If they have a crappy cell signal it takes ages to upload or even times out!

Is there anything that can be done about this? Anyone got any ideas?

Thanks
RocketRod
Posts: 907
Joined: Wed Aug 06, 2008 4:22 am
Location: Melbourne

Re: Cant get Scale_Image to work

Post by RocketRod »

Sadly my users had to stop uploading pictures via mobile phones as it takes far too long to upload them. Until something is done as you said to resize before uploading, then I can't see how one can use this feature at all on mobile devices.

Cheers Rod
Jaymer
Posts: 2528
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Cant get Scale_Image to work

Post by Jaymer »

For android, you can get an 'alternate' camera app that does this scaling BEFORE the upload.
Makes it very easy to upload smaller images.
Haven't looked on Apple (which I am). A customer reported this to me.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
jannes
Posts: 105
Joined: Tue Jul 02, 2019 12:22 pm

Re: Cant get Scale_Image to work

Post by jannes »

I'm using in the business rules :

IF IMAGE_WIDTH (PersPeri.Foto2) <= 300 AND IMAGE_HEIGHT(PersPeri.Foto2) <= 300 THEN
END PROCESS
ELSE
IF IMAGE_WIDTH (PersPeri.Foto2) > IMAGE_HEIGHT (PersPeri.Foto2) THEN
PersPeri.Foto2 = SCALE_IMAGE(PersPeri.Foto2, 300, IMAGE_HEIGHT (PersPeri.Foto2) / IMAGE_WIDTH (PersPeri.Foto2) * 300)
ELSE
PersPeri.Foto2 = SCALE_IMAGE(PersPeri.Foto2, IMAGE_WIDTH (PersPeri.Foto2) / IMAGE_HEIGHT (PersPeri.Foto2) * 300, 300 )

Unfortunately the photo is turned 90'.
This seems to a bug in the java plugin.
So I ask the users to take a photo in landscape format. In that case it will not turn 90'.
Jaymer
Posts: 2528
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Cant get Scale_Image to work

Post by Jaymer »

Have written lots on this subject. Several years now.
Have scaled a lot.
EXIF data.
Have always reported error was on Vlad’s side when scaling.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
jannes
Posts: 105
Joined: Tue Jul 02, 2019 12:22 pm

Re: Cant get Scale_Image to work

Post by jannes »

In the meantime I developed a resize application / module (in Delphi).
It is called in rule2.
Until now it works fine, pictures are resized / scaled from 3 a 4 Mb to 15 a 20 kB.

Rule0
IF FILE_EXISTS ('c:/mytemp/' +PersPeri.ID + '.jpg') = 'Yes' THEN
DELETE FILE 'c:/mytemp/' +PersPeri.ID + '.jpg'

Rule1
IF PersPeri.Foto2 IS DEFINED THEN
EXPORT DOCUMENT PersPeri.Foto2 TO FILE 'c:/mytemp/' +PersPeri.ID + '.jpg'

Rule2
IF FILE_EXISTS ('c:/mytemp/' +PersPeri.ID + '.jpg') = 'Yes' THEN
EXECUTE PROGRAM 'resizephoto.exe c:/mytemp/' +PersPeri.ID + '.jpg'
IMPORT DOCUMENT PersPeri.Foto2 FROM 'c:/mytemp/' +PersPeri.ID + '_scaled.jpg'
Post Reply