How do I make uncropped (full proportion) thumbnails?

I would like to make my thumbnails stay in their correct proportions, and always have the longest side resizes to 125px.

So if an image was 500x750 the thumbnail would be be 84x125.
If an image is is 750x500 the thumbnail will be 125x84.

Could someone help me!

Thanks!

Cooper

PS. I searched and browsed, and I feel like this has been discussed before, but I couldn't find a clear and concise description.

Comments

  • trisweb Administrator
    `zp-config.php`, the image thumbnail options are near the bottom. Just set the crop setting to false!

    Some themes (eg: stopdesign) may override this if they have special design requirements, so those would require going into the theme code (and probably the HTML/CSS design) to change.
  • Even though this is an old post, thanks for the tip. Unchecking "Crop thumbnails" in the admin didn't do anything, but editing `zp-config.php` did. (also applies to image size)

    ...should the 'zen' folder also be 777'd?
  • Hi!

    I'm just starting in on doing another new gallery display, so I'm just checking out the new 1.1 release. Great work!

    As for thumbnails, I ran into this issue myself, and thought I'd share my solution.

    In a nutshell, if I've got "Images size is longest size" checked yes, and "Crop thumbnails" unchecked in the admin / options / image display settings, I would expect to have the images uncropped, and scaled to fit within the thumb size. To do this, you just need a little change to i.php

    Add this line to the "Set the config variables for convenience" section at the top:
    `

    $thumb_crop = getOption('thumb_crop');

    `

    Then find this line:
    `

    if ((!$thumb && $size && $image_use_longest_side && $h > $w) || ($thumb && $h <= $w) || $height) {<br />
    `

    and change it to:
    `

    if ($thumb && !$thumb_crop && $image_use_longest_side ) {

    if( ($cw/$ch) > ($w/$h) ){

    $newh = $ch;

    $neww = $w*($ch/$h);

    }else{

    $neww = $cw;

    $newh = $h*($cw/$w);

    }

    $crop=0;

    } else if ((!$thumb && $size && $image_use_longest_side && $h > $w) || ($thumb && $h <= $w) || $height) {<br />
    `

    Of course, not every theme is going to work with that, but if you want the ability to get the intuitive (at least, that's the way I think it should work with those settings), then this should do the trick.
  • pdm Member
    This behavior was not intuitive to me at all. I would expect if I specify a thumbnail size with a single value, I would be specifying the maximum dimension of any side, not the minimum. There is no predictability with specifying the size of the shortest side, or at least there shoul be some option to specify what you want in the config area and make it obvious what you are getting. Thanks Alex for your suggested patch, i'll try it out.
  • Hi,

    I´ve been trying to do something (in theory simple) with thumbnails but with no luck:

    1) Fixed size in both dimensions so gallery looks like a regular grid
    2) No cropping

    This means images have to be scaled and padded to fit thumb size. I´ve checked several threads but none of the proposed solutions seems to work with ZenPhoto 1.1.5 (note i.php has changed completely so above hack no longer applies).

    Please help. BTW, shouldn't this be the default behavior if crop is disabled and thumb sizes are specified?

    Thanks in advance,

    Fede
  • acrylian Administrator, Developer
    No, the longest side is taken as size. How do you want to fix both dimension for a grid, it will never look like a symmetrical grid. You could adjust the css surrounding the thumbs.

    Or you try modifiying album.php with this function: http://www.zenphoto.org/documentation/Zenphoto/_template-functions.php.html#functionprintCustomSizedImageMaxHeight

    But since that relies on the sized images size and not the thumbnail size, you probably should use this or the printCustomSizedfunction on image.php, too.

    Anyway, I guess I should modify the printCustomSizedImageMaxHeight with an option for the width...
  • I tried to find the section in i.php mentioned above by Alex but coudn't. I too want exactly what c-unit explains in his/her post.
  • Hi acrylian, thanks for the quick replay.
    I've been already playing with the getCustom* functions but as far as I could see they do not add any padding on the images, so you either get the size you want in one dimension or you get a deformed image (obviously). So probably the best thing to do would be to workaround this on the CSS. I have little experience with CSS, do you know of any example around doing something similar? Thanks,

    --f
  • acrylian Administrator, Developer
    @macalter: Set the thumbnails in the admin to not cropping.

    @fardanz: Of course that function does not add padding to the images. That is the job of CSS. Please understand that we can't teach the basics of CSS here, since this is not a specific zenphoto issue. Please refer one of the many resources on the web.
  • I had this hack working in 1.1, but 1.15 seems to have changed the i.php file, taking the resizing out and putting it into the function 'cacheGalleryImage' in functions-image.php. I cannot seem to get it working the same. Could you post where and what to change to get the proportional, non-cropped thumbnails working? Thanks.
  • Your best bet is to use the customsized image function(s) to create your thumbs. Hacking the zenphoto core is bound to cause you problems like you just experienced. That said, The code that got moved is really unchanged but for the location, so you could just re apply your hack to the code in its new locations.
  • Hello,

    I found such resolution, no need zenphoto core hack:
    `<?php<br />
    if (isLandscape()) {

    $myImgSrc = getCustomImageURL(NULL,166,NULL);

    }

    else {

    $myImgSrc = getCustomImageURL(NULL,NULL,166);

    }

    ?>

    image" />`

    or with next_image() loop:

    `<?php while (next_image(false, $firstPageImages)): ?>



    <?php endwhile; ?>`
  • ah yes, more clear:
    `<?php <br />
    $desirableThumbWidth = 150;

    $desirableThumbHeight = 100;

    if (isLandscape()) {

    $myImgSrc = getCustomImageURL(NULL,$desirableThumbWidth,NULL);

    }

    else {

    $myImgSrc = getCustomImageURL(NULL,NULL,$desirableThumbHeight);

    }

    ?>

    image" />`
  • According to spec http://code.google.com/apis/picasaweb/reference.html#Parameters
    thumbsize parameter can be cropped or uncropped up to 800px size. But
    400c size is not allowed (biggest allowed cropped size is 160c).
    For example, request http://picasaweb.google.com/data/feed/api/user/greeceru/album/test?th...
    says "thumbsize: That is not one of the acceptable values".
    Did I something wrong? Thanks.
  • acrylian Administrator, Developer
    Sorry, this is the forum for Zenphoto, not Picasaweb. Our documentation is found on our user guide page...
  • Adagio Member
    So I'm looking at Options>Image Display for the thumbnail scaling options and see none. I thought they were there yesterday. What am I missing?
  • acrylian Administrator, Developer
    These are under the "theme options" tab.
  • Adagio Member
    Duh. Thanks, acrylian.
  • Searched a long time for this - thanks!
  • I got this to work fine for images in albums (Thanks!) - but I can't figure out how to make it work for the preview image of an album. Is it possible to do in a template? `isLandscape()` does not seem to work for album thumbs.
  • acrylian Administrator, Developer
    Right that does not work with album thumbs. If you use the nightly build there are now new functions for this (currently undocumented!):
    `getCustomAlbumThumbMaxSpace()` and `printCustomAlbumThumbMaxSpace()` (only for album thumbs) as well as
    `getCustomSizedImageMaxSpace()` and `printCustomSizedImageMaxSpace()` (for both the thumbas within an album and the sized image).
    See template-function.php directly for parameters
  • Nice! I'll have to try that out. Also looks much cleaner than this 'workaround' for image thumbs. I understand maybe not having this option in the zenphoto GUI because the CSS in templates is not built for it, but for those of us rolling our own themes, a function is a good step forward.
  • @ acrylian

    How would I implement those functions? And where?

    I'm on version 1.2.8 [4881]

    My client's site is for fine art and nature photography. He doesn't like that his photos are getting cropped.. and not showing the full proportion. If I turn cropping off it's a mess because he has horizontal and vertical photos all over the place.
  • acrylian Administrator, Developer
    You really should read our theming tutorial first to learn how Zenphoto themes work. You will of course also have to adjust the theme's CSS.
Sign In or Register to comment.