This question is answered.


Permlink Replies: 6 - Pages: 1 - Last Post: 26 May 21, 12:52 Last Post By: davidekholm Threads: [ Previous | Next ]
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Incorrect originalWidth for images in portrait mode?
Posted: 25 May 21, 10:23
 
  Click to reply to this thread Reply
In this srcset test album a show as first two images an image of the same size, but the first image in landscape mode and the 2nd in portrait mode. I show below an image o.a. ${originalWidth}x${originalHeight} and $imageWidth}x{$imageHeight} .

The first image shows as original dimensions 4032x3024 which is correct. However for the 2nd image the same value is displayed. I think this should be 3024x4032. Is this a bug?
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: Incorrect originalWidth for images in portrait mode?
Posted: 25 May 21, 16:24   in response to: AndreWolff in response to: AndreWolff
Correct
  Click to reply to this thread Reply
AndreWolff wrote:
In this srcset test album a show as first two images an image of the same size, but the first image in landscape mode and the 2nd in portrait mode. I show below an image o.a. ${originalWidth}x${originalHeight} and $imageWidth}x{$imageHeight} .

The first image shows as original dimensions 4032x3024 which is correct. However for the 2nd image the same value is displayed. I think this should be 3024x4032. Is this a bug?


If I designed this from scratch now, I'd probably make the originalWidth and originalHeight variables respect how the image is oriented when viewed. However, I believe the way it works now is that these variables reflects the pixel width and height of the physical image on disk. It may very well be that this is a portrait image (according to the image orientation metadata) that has the physical pixels laid out in a landscape manner. To be guaranteed that you get the original width and height adjusted for the orientation, call getSize() on the current AlbumObject.
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: Incorrect originalWidth for images in portrait mode?
Posted: 26 May 21, 09:20   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
David, you are correct, his picture is shot with a normal camera, so it is 90 degrees rotated

Global variable ${orientation} displays 'left', for the first LS picture it shows 'normal'.
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: Incorrect originalWidth for images in portrait mode?
Posted: 26 May 21, 10:48   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
So, for whatever it's worth, you can consider ${originalWidth} and ${originalHeight} as describing the width and height of the physical pixel data of the original file. Use getSize() to get interpreted values.
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: Incorrect originalWidth for images in portrait mode?
Posted: 26 May 21, 11:03   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Use getSize() to get interpreted values.
Sorry David, you have for me, as stupid Java programmer, to show a fully coded example!
For me is the use of the global variable orientation much more attractive!
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: Incorrect originalWidth for images in portrait mode?
Posted: 26 May 21, 12:48   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
davidekholm wrote:
Use getSize() to get interpreted values.
Sorry David, you have for me, as stupid Java programmer, to show a fully coded example!
For me is the use of the global variable orientation much more attractive!

"orientation" is a local variable, but by all means, use it if you prefer so. Here's a full example to get the visual width of the current object:
currentObject.getSize().getWidth()
davidekholm

Posts: 3,442
Registered: 18-Oct-2002
Re: Incorrect originalWidth for images in portrait mode?
Posted: 26 May 21, 12:51   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
By the way, if you prefer to use the "orientation" variable, pay attention that it is in fact an object and not a plain string, so you can easily check whether the image is rotated to the left or right (i.e. that originalWidth and originalHeight should be flipped), just say
if (orientation.isRotated()) { ... }
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums