Change thumbnail crop position?

Is there a way to change the crop position for thumbnails from centered? I would like my thumbnails that come from the larger pictures cropped so that its:

vertical - top
horizontal center

is there anyway to acheive this? I tried searching for an answer to no avail

Comments

  • Yeah. You'll have to edit i.php.

    Go down to line 205 which should be:
    `if ($cy === false) $cy = round(($newh - $ch) / 2);`

    Comment that line out by placing // before it so your end result should look like this:
    `//if ($cy === false) $cy = round(($newh - $ch) / 2);`

    Then just save it, clear your cache, and then reload the page.
  • roraz Member
    hi

    I tried to do as you described but in the i.php file that i have, there is only 101 lines and no code like you described above.

    Im using the zen photo files frm the version available from the front page 1.0.3

    is there a way to do it with this version?
  • roraz Member
    anybody?
  • roraz Member
    can anybody help me with this? It says here - http://www.zenphoto.org/support/topic.php?id=562

    that you can "Image sizing/cropping any way you want (for theme developers and/or users and/or plugin authors)" within v1.03

    I looked at the stopdesign theme and saw this:

    <?php printCustomAlbumThumbImage(getAlbumTitle(), null, 200, null, 210, 210); ?>

    could anyone explain the variables used? I know the 210's are for height and width, but what about the 200 and nulls? I couldn't find any documentation concerning this...

    basically what I want to achieve is thumbnails that are what ever height and width, but are cropped from the top downwards and not centered cropped?!
  • You are lookin for line 554 thru 560 of template-functions.php in the zen directory
    printCustomAlbumThumbImage($alt, $size, $width=NULL, $height=NULL, $cropw=NULL, $croph=NULL, $cropx=NULL, $cropy=null, $class=NULL, $id=NULL)
  • anychance you can breakdown the different parameters there on what each of them do, or give me a link to somewhere that does? =)

    My problem is I want a set width and height cropped thumbnail but, when i set it most of the time faces are cut out of thumbs and you only see bodies. So i need to change the crop position so that its not so centered and more towards the top of each thumb/picture??!
  • anybody?
  • I am sorry, I havent had any time outside of work to take a look into this to give you a better explaination. Take a look into the ThinkDreams theme or the Stopdesign theme as to where to get ideas for the thumbnail size and start playing around with it in the mean time. Otherwise I can see what I can dig up over the weekend.
  • cheers man - will do, any help would be appreciated
  • trisweb Administrator
    You're going to have to go into your theme file and change all instances of printAlbumThumbImage / printThumbImage (or the like; I'm not looking at it right now) into printCustomAlbumThumbImage / printCustomThumbImage with the variables you need. So, like:

    printCustomAlbumThumbImage('', 100, NULL, NULL, 80, 80, -1, 0, NULL, NULL)

    will get you a 100-width image, cropped to 80x80, from the x-center/y-top (-1 means center-x, 0 means top-y).

    So that's all done in the theme with that function. Let me know if you need any more help.
  • no man, thats great. I just needed a breakdown of each variable so I would know what to put in each to make it work right

    cheers
  • This is what Im trying to implement on my album.php page:

    <?php printCustomThumbImage(getImageTitle(), null, 85, null, 85, 85, -1, 0, null, null); ?>

    however when I try to view an album page I get an error message for the line that the custom cropped/sized thumbnail code is on, though im not getting any errors whilst using this (ie this custom sized/crpped code works):

    <?php printCustomAlbumThumbImage(getAlbumTitle(), null, 230, null, 210, 100, null, 30, 'reflect', null); ?>

    on my index page that shows the individual albums??!!
  • trisweb Administrator
    It might not be the right function.... let me check...

    Nope, it wasn't. Here's the right one:

    `printCustomSizedImage($alt, $size, $width, $height, $cropw, $croph, $cropx, $cropy, $class, $id)`

    We really need some good documentation on those template functions... I'll work on getting someone to do that.
  • cheers man that worked a treat
  • Sorry to be pedantic about this, but Im trying to my theme just right ;)

    The previous and next image thumbnails on the image.php page are done differently then the other images in that there isn't a php code to call in the image rather the img source with the php for the next image thumbnail url. eg:

    <img src="<?=getPrevImageThumb(); ?>" />

    is there a way to apply a custom crop to this?

    or is there a way to hack zenphoto, so that instead of center/center (x/y axis) crop for general thumbs its center/top?? That would make things abit simpler
  • trisweb Administrator
    Yeah, if you just want to hack i.php to use custom crop info for the generic request, that might be much easier. Look at i.php and see if you can set cropy, that might be enough. I gtg, but lemme know if you need more help.
  • Looking at iphp I have know idea =)

    Im guessing its this section that says:

    // If s=thumb, Set up for the default thumbnail settings.
    $size = $_GET['s'];
    if ($size == "thumb") {
    $thumb = true;
    if ($thumb_crop) {
    if ($thumb_crop_width > $thumb_size) $thumb_crop_width = $thumb_size;
    if ($thumb_crop_height > $thumb_size) $thumb_crop_height = $thumb_size;
    $cw = $thumb_crop_width;
    $ch = $thumb_crop_height;
    $crop = true;
    } else {
    $crop = $cw = $ch = false;
    }
    $size = round($thumb_size);
    $quality = round($thumb_quality);

    // Otherwise, populate the parameters from the URI
    } else {
    if ($size == "default") {
    $size = $image_default_size;
    } else if (empty($size) || !is_numeric($size)) {
    $size = false; // 0 isn't a valid size anyway, so this is OK.
    } else {
    $size = round($size);
    }

    if (isset($_GET['w'])) { $width = round($_GET['w']); }
    if (isset($_GET['h'])) { $height = round($_GET['h']); }
    if (isset($_GET['cw'])) { $cw = round($_GET['cw']); $crop = true; }
    if (isset($_GET['ch'])) { $ch = round($_GET['ch']); $crop = true; }
    if (isset($_GET['cx'])) { $cx = round($_GET['cx']); }
    if (isset($_GET['cy'])) { $cy = round($_GET['cy']); }
    if (isset($_GET['q'])) { $quality = round($_GET['q']); }
    }

    $postfix_string = ($size ? "_$size" : "") . ($width ? "_w$width" : "")
    . ($height ? "_h$height" : "") . ($cw ? "_cw$cw" : "") . ($ch ? "_ch$ch" : "")
    . (is_numeric($cx) ? "_cx$cx" : "") . (is_numeric($cy) ? "_cy$cy" : "");

    } else {
    // No image parameters specified; return the original image.
    header("Location: " . PROTOCOL . "://" . $_SERVER['HTTP_HOST'] . WEBPATH
    . "/albums/" . rawurlencode($album) . "/" . rawurlencode($image));
    return;
    }

    though im not sure what to alter to make it customed cropped??
  • I've managed to alter this code (well, the way it is in the current version - the lines that set the value of $cy), but I'm still having trouble. What I'm finding is that this works when images are uploaded individually but not if they are uploaded via FTP.

    Any suggestions? Is there another function somewhere that would be used for bulk uploads? I'll keep looking...
  • acrylian Administrator, Developer
    You can upload .zip-files with images.
  • And that will use the altered function? I guess I'll have to try it and see...
  • Uploading zip files doesn't work at all for me. It just gives me an error saying that no images were uploaded. I'd really rather not have to create zip files anyway.

    There's got to be a function somewhere that's creating those thumbnails. But where??
  • Megan

    The code should be dependent on how the images were uploaded. What is it that you are seeing that is different in the two cases?
  • When uploaded through the admin interface it does use the crop function in i.php. When images are uploaded via FTP it doesn't use that function but just crops them from the middle.

    I gave up on trying to fix that and just used the generate custom thumb functions instead.
Sign In or Register to comment.