can't resize an image that has been rotated?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

can't resize an image that has been rotated?

Post by dunbarx » Tue Jun 20, 2023 8:12 pm

This came from experimenting with a thread:
https://forums.livecode.com/viewtopic.php?f=7&t=37985

Anyway, if one imports an image onto a card and then sets its angle to some value, that image can no longer be resized.

Just me again?

Craig

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am

Re: can't resize an image that has been rotated?

Post by RCozens » Wed Jun 21, 2023 6:01 pm

Hi Craig,

I can resize a rotated image here (LC9.6.9, Win10) by changing the height and/or width using the Property Inspector or the Message Box.

I would note that rotating an image automatically changes the image dimensions.

Cheers,

Rob
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: can't resize an image that has been rotated?

Post by richmond62 » Wed Jun 21, 2023 8:44 pm

I used ROTATE, and NOT set the angle.

Code: Select all

on mouseUp
   rotate img "cat" by 45
   set the width of img "cat" to 400
   set the height of img "cat" to 400
end mouseUp
Image NOT locked.
-
puss.png
-
Xubuntu Linux as MacOS 14 developer beta hoses LiveCode.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: can't resize an image that has been rotated?

Post by dunbarx » Thu Jun 22, 2023 2:12 am

Hi.

I was unclear. One cannot resize with the pointer tool in edit mode. All the programmatic methods do indeed work.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: can't resize an image that has been rotated?

Post by richmond62 » Thu Jun 22, 2023 11:18 am

This:

Code: Select all

on mouseUp
   set the angle of img "cat" to 45
   set the width of img "cat" to 400
   set the height of img "cat" to 400
end mouseUp
did NOT work!
-
Screen Shot 2023-06-22 at 1.17.19 pm.png
-
MacOS 10.7.5 , LC 8.1.10

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: can't resize an image that has been rotated?

Post by dunbarx » Thu Jun 22, 2023 1:35 pm

Hmmm.

My original point was this. If one imports an image file then selects the pointer tool, one can resize the image by hand. If however, one sets the angle of that image to some value, one can no longer resize with the pointer tool. No other properties have been changed by simply setting the angle (I think).

That these commands do not work on an image whose angle is not 0 is odd. Oddly, if one resets the angle back to "0", all of those other things work.

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: can't resize an image that has been rotated?

Post by bn » Thu Jun 22, 2023 4:52 pm

dunbarx wrote:
Thu Jun 22, 2023 1:35 pm
My original point was this. If one imports an image file then selects the pointer tool, one can resize the image by hand. If however, one sets the angle of that image to some value, one can no longer resize with the pointer tool. No other properties have been changed by simply setting the angle (I think).
That these commands do not work on an image whose angle is not 0 is odd. Oddly, if one resets the angle back to "0", all of those other things work.
Craig,

At first I did not understand what you were describing and now I see the same behavior you mention.
However I think it is more a documentation omission not to mention that fact than a bug. I think it is actually a feature. Because once you set the angle of an image (via message box or Properties Inspector or code) you would change that angle when manually changing the image dimensions with the pointer tool.

Kind regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: can't resize an image that has been rotated?

Post by bn » Thu Jun 22, 2023 5:01 pm

richmond62 wrote:
Wed Jun 21, 2023 8:44 pm
I used ROTATE, and NOT set the angle.
To see the ROTATE command in action try this as script of a scrollbar

Code: Select all

on scrollbarDrag pValue
   rotate image "cat" by pValue
end scrollbarDrag
and move the scrollbar repeatedly.
Poor cat...
(It is mentioned in the dictionary)

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: can't resize an image that has been rotated?

Post by dunbarx » Thu Jun 22, 2023 5:53 pm

@Richmond. Yes, setting the angle of an image does not have the distortion issues that rotating does. As Bernd said, the dictionary warns about this.

@Bernd. Changing the width or height of an image distorts that image in the "usual" way. If the image shows an object "pictured" at some angle, it does not change the "angle" of the image itself, though it might look like it does. It just distorts it as usual, and the image does the best it can.

I agree this appears to have been locked on purpose, but I really do not see why. If one changes the width and height of an image in its proper proportion, one gets an accurate smaller version of that image. This might be desirable. Surely one can set those properties before setting the angle, but I still don't see the benefit of closing that option down.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: can't resize an image that has been rotated?

Post by dunbarx » Thu Jun 22, 2023 6:09 pm

When setting a new width and height of an imported image, the lockLoc must be set to true before changing the angle, or the original imported rect will be restored. Again, I do not see how this prevents unwanted behavior.

This setting of the lockLoc is essential if one wants to prevent LC from restoring the original imported rect after messing around with that image in some way. For example, if one imports an image and then changes its rect, if that image is then duplicated, the copy will be at the original rect.

Never mind setting angles, this general behavior was considered by the LC developers early on, and dealt with they way they did.

I invariably set the lockLoc immediately after importing any image.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: can't resize an image that has been rotated?

Post by richmond62 » Fri Jun 23, 2023 10:52 am

Poor cat...
Indeed: rapid degradation of the image.

Something that a fair few of us knew about about 20 years ago.

BUT, surely that is not the thing we are considering.

What we are considering (well, at least last time I looked) was how to resize, using code,
an image that had been rotated in either of the 2 ways offered by LiveCode.

As rotate chews images like a T-Rex gobbled up a small, vegetarian dinosaur,
and images rotated using set the angle don't seem to be capable of being resized,
if I were wanting to do this on a semi-fulltime basis I would hunt around for a way to do
this outwith LiveCode [GIMP springs to mind].

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: can't resize an image that has been rotated?

Post by richmond62 » Fri Jun 23, 2023 10:56 am

THIS is my 'Quick-n-Dirty' way of doing things:

Code: Select all

on mouseUp
   set the angle of img "cat" to 45
   import snapshot from img "cat"
   delete img "cat"
   set the name of the last img to "cat"
   set the width of img "cat" to 400
   set the height of img "cat" to 400
end mouseUp
-
Screen Shot 2023-06-23 at 12.55.11 pm.png
-
Still a bit . . .
-
shaggy.jpg
shaggy.jpg (6.71 KiB) Viewed 9029 times
-
round the edges. 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: can't resize an image that has been rotated?

Post by richmond62 » Fri Jun 23, 2023 12:38 pm

When I imported an SVG image into 9.6.3 and the did this:

Code: Select all

rotate img "scarab" by 45
set the width of img "scarab" to 482
set the height of img "scarab" to 560
The ONLY reason the image went 'all fuzzy' was because I was stupid enough to import and image which the internet supplier
described as an SVG, BUT was NOT drawn with vector graphics, just a bitmapped image inside an SVG wrapper.
-
B1.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: can't resize an image that has been rotated?

Post by richmond62 » Fri Jun 23, 2023 12:57 pm

AND here, with what is, supposedly, a vector SVG, is a complete load of rubbish:

Code: Select all

on mouseUp
   rotate img "beetle" by 45
   set the width of img "beetle" to 450
   set the height of img "beetle" to 450
   set the top of img "beetle" to 300
end mouseUp
-
B2.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: can't resize an image that has been rotated?

Post by richmond62 » Sat Jun 24, 2023 12:51 pm

I wonder if this means that LC on performing a rotate on an imported SVG image converts it into a bitmapped image?

Post Reply