Portraits Rotating Properly but Displaying Squished?

I'm having problems with portrait jpgs getting rotated properly but displaying as squished/cropped in single picture view. This is a fresh install of latest stable with all default settings, with the exception of the enabling of auto rotate, and the default theme.

I get the following results with portrait JPGs straight off my Canon 7D:

1) Thumbnail jpg is rotated just fine, looks good.
2) Single photo view jpg is rotated fine (I can verify this by right clicking the image and selecting "View image" in Firefox) but displayed as landscape, stretched horizontally and cropped vertically.
3) Full original jpg rotated properly.

This happens with all new, never-before-databased images as well, so it's not an issue of the database remembering image dimensions before enabling auto rotate.

Any thoughts? Could an older library of something outside of zen be to blame, and if so, what would be the likely culprit?

Comments

  • acrylian Administrator, Developer
    Have you checked if the image is really squished by generation or simply by the html/css setting. Copy the image and look at its actual dimensions. If itself has the real dimensions as wished there is probably something in your theme's htlm or css wrong (no standard theme should do this).
  • Thanks for responding.

    The actual jpg is indeed being properly rotated/resized. If I download the image or right click it to view just the JPG itself, it is properly sized - in this case, 397x595 pixels.

    The display size, however, is set to 595x397 pixels. So if I right click the image in Firefox and choose properties, it says: "397px × 595px (scaled to 595px × 397px)"

    As for a theme / CSS being the cause, as I mentioned, this is a fresh install of zen downloaded and installed just a few hours ago. I have literally done nothing but enabled auto rotate - everything else is pure default. So no 3rd party themes or other tinkering going on. It just seems like the image is being handled properly, but the database is not getting the final display size correct.

    One interesting thing though is that I went into the edit function of a random image, and I noticed the option to rotate is grayed out. This is increasingly making me think I have a weird or old version of some library that zen depends upon that is to blame.

    Any thoughts?
  • acrylian Administrator, Developer
    It might be that the actualy meta data of the dimensions of your image is wrong.

    Regarding libaries what does setup tell you? If the rotate option is greyed out you either don't have the option checked or your the GDlibary on your server does not support it.
  • You also have not mentioned what theme you are using nor what theme options and image options are set.
  • Acrylian: Setup shows the following:

    PHP version 5.2.2
    Graphics support: PHP GD library bundled (2.0.34 compatible)
    MySQL version 5.0.41

    All green checkmarks for the various PHP, GD, and MySQL requirements.

    -----------------

    sbillard: I did state "This is a fresh install of latest stable with all default settings, with the exception of the enabling of auto rotate, and the default theme." in my first post and reiterated that point in my second post as well.

    Indeed, everything is default: the theme, the theme settings, regular settings - absolutely everything - with the exception of the "Auto rotate" button I checked on the Image options page.

    But just to be sure I wasn't stupidly forgetting something else I had changed, I just did the following sanity check:

    1) Downloaded zenphoto-1.2.8_RC1.zip off of the home page, extracted to new zentest folder on my server.
    2) Created fresh zen2 database, copied zp-config.php.source to zp-data and configured mysql login info accordingly. Did "chmod 777 zenphoto -R" to quickly take care of all permissions issues, just for this test.
    3) Ran setup, all green checkmarks on the program stuff. Created admin user. Logged in.
    4) Checked "Auto rotate" on Image options page, but touched *nothing* else.
    5) Put a "Test" folder in albums, full of two straight-off-the-camera portrait JPGs from my Canon 7D, and one portait jpg from my old Canon 350D.

    The results? Exact same problem. Properly rotated jpgs across the board, but in single picture view the image is again stretched and cropped, smashing a portrait image into the display size of a landscape. (And just in case it's relevant, I get the same view in both Firefox 3.5 and Internet Explorer 8.)

    Given that strict test methodology, it seems like it *has* to be either an intrinsic bug in zen (not bloody likely, I suspect) or a server / library problem on my end.
  • I was just poking around, and I found out something strange. If I "refresh the metadata" from the overview page, the problem is immediately fixed for all existing images. They appear correctly, non-scaled, and everything is good. If I then add some new portrait JPGs, they again appear squished/cropped, but after a refresh they too become fixed.

    It's almost as if the metadata is not being refreshed automatically after the rotate. Is it possible this is actually a bug?

    Also, after the metadata refresh, the option to rotate becomes available in the image settings
  • What happens if you do not rotate the images? Maybe you images have been "half rotated". That is they have their dimensions set as if rotated but are still marked as needing rotation.

    The only other thing I have seen like this is when you have viewed the image before rotation, rotate it, and then revisit the page. For some reason sometimes the image is refreshed but the actual page is not so the image gets squished into the old html width/height settings.
  • If I don't check "auto rotate" the portrait images display on their sides, but are otherwise perfect.

    It seems like the images are being rotated (as in, the physical jpgs generated are properly rotated) but the metadata accompanying the image that tells zen how big to display the image, etc.. is not being updated after the rotation. Instead, it's using the default, non-rotated metadata.

    As for viewing the images before rotation, I too thought that might be causing issues, either because of my browser caching or zen itself. That's why on my most recent sanity check (where I redid everything from scratch) I specifically used new images that I had never uploaded before, and I did not put them in the albums folder until *after* I had set the auto rotate function.

    So, the error shows itself with a fresh all-default install (with the exception of auto-rotate turned on) and never before uploaded or viewed images. And it the problem is fixed immediately upon performing a metadata refresh.

    I guess I could just get into the habit of refreshing the metadata everytime I add pictures to my site, but the tinkerer side of me wants to figure out the root of the problem.
  • Ah, the magic bit of information. Yes, the order of checking the metadata and updating the diminsions was backward. That will be fixed in the nightly. Let us know if it resolves the problem.
  • Just grabbed the updated class-image.php from SVN for a quick test, overwrote my existing class-image.php, and it works perfectly now. Thanks for fixing this!
  • I have this exact same problem tonight. Did the bug return? Or do I have some other setting all wrong. I too am on default everything, and all of the descriptions are exactly the same.
    The thumbnails are fine. It's just the single image that is stretched horizontally.

    I too can update the metadata after every upload, but that seems like a poor solution. I'm using Zenphoto version 1.4.2.2 [9365]

    thanks for any help!
  • acrylian Administrator, Developer
    As said you need to try the nightly build.
  • I was able to reproduce this problem by uploading an image via ftp to the album directory while the auto rotate feature was off. I then visited the uploaded image in the gallery where it was displayed on it's side. I then enabled the auto rotate feature and refreshed the page. It was displayed in the correct orientation, but the image was stretched out. To correct this, I manually updated the database via phpMyAdmin using the query:

    `UPDATE gallery_images SET height = '', width = '' WHERE filename = "IMG_0001.JPG"`

    I then refreshed the image in the gallery and the image was displayed in the correct orientation and the correct width and height. As an extra caution, I ran the same query for all of the files in the database by omitting the `WHERE` clause.

    I use rsync to upload my photos directly to the albums/ directory. I do not use the admin pages, which might be some of the reason why I had seen this issue.
Sign In or Register to comment.