Hello,
I just upgraded from Zenphoto 1.1.5 to 1.2.4. Everything seems fine except for the custom functions I was using to generate thumbnails in the old version. These are the functions I'm using:
On the index:
`<?php printCustomAlbumThumbImage(getImageTitle(), 180, 180, 180, 180, 180, 0, 10); ?>`
On the album pages:
` <?php printCustomSizedImage(getImageTitle(), 150, 150, 150, 150, 150, 0, -10, null, null, false); ?>`
These work fine in 1.1.5 but in 1.2.4 the thumbnails are really weirdly distorted and stretched out. Any numbers I put in for the crop positions seem to cause the same problems.
Here's my gallery:
http://pole.uwaterloo.ca/cpadev/news/gallery/Research/Also, a few questions about the parameters in these functions:
What exactly does "size" mean? How is this used in relation to the height and width dimensions? And the crop dimensions? I'm confused about why the numbers I used get the results I they did.
Does cropping really start at the top-left corner? Because it looks to me that it's centered on the image (e.g. I have 180px images with a 150px crop - the crop takes off about 15 pixels on either side, rather than 30px at the bottom/right). If this is the case, then where are cropx and cropy measured from?
Do these parameters override the settings in theme options?
Thanks for any help.
Comments
first the crop is done by taking a slice of the image from (cropx,cropy) to (cropx+cropw,cropy+croph) then the result is resized to fit either size or height x width. If cropx or corpy are not given then the value used is 1/2 the "trimmed" area. In other words if both are not provided, the crop is centered on the image. Zero is, unfortunately, the same as not provided due to the foibles of PHP. You would have to use 1 i you want the edge of the image.
The parameters override any settings. More to the point, there are no theme settings for the custom functions.
` <?php printCustomSizedImage(getImageTitle(), 150, null, null, 15000, 15000, 1, 1, null, null, false); ?>`
Which gets me something resembling a normally scaled image, although they are being scaled on the long side instead of cropping.
The question is: why in the world did I have to go up to 15000 for the cropw and croph to get a normal section of the image???
Does the Stop Design theme work okay for others? For me it has the same problems I was having originally.
So the thumbnails use the admin setting under image size for longest side etc.? Changing that setting doesn't seem to make a difference.
Cropw and croph are relative to the full sized image, so yours would have to be 15000x15000 for that to be correct. I doubt they are that large, so there must be someting else wrong.
At this point I would a clean install of the nightly build. Maybe there are some bad files in your install. (Just a guess, though.)
Are all the details about how these parameters work documented anywhere? That would be useful.
Is there more custom thumb cropping in admin than what's under theme options? (thumb size, crop thumbnails).
I think the stop design theme is actually working now, dont' know why it was showing the distorted thumbnails before. I notice he's using get custom sized image so maybe I'll try that ... All I'm trying to do is move the crop position up a bit so that peoples' heads don't get cut off in the thumbnails.
This worked fine for me in 1.1.5 but I think I might have messed around with the zp-core files at the time...
`
<?php
if (isLandscape()){ // if it's landscape, just print a normal thumbnail
$ch = $_zp_current_image->getHeight();
$cx = ($_zp_current_image->getWidth()/2) - ($ch/2);
printCustomSizedImage(getImageTitle(), null, 150, 150, $ch, $ch, $cx, null);
} else { // if it's portrait, set the crop dimensions to match the width of the image
$cw = $_zp_current_image->getWidth();
printCustomSizedImage(getImageTitle(), null, 150, 150, $cw, $cw, null, 50);
}
?>
`
Not sure why I had to write that formula to get the $cx position for the landscape images... otherwise it was resizing & squishing them.
New question: isLandscape() and getHeight()/getWidth() aren't available for album thumbs. Is there anything else I could use instead?
Thanks a million for all your help!
(sorry about my crappy PHP skills!)
`
<?php<br />
$thumb = getAlbumThumb();
echo "
" . $thumb . "
";if ($thumb->getWidth() >= $thumb->getHeight()) {
echo "
landscape
";}
?>
`
'.$thumb.'
';` will also need to change since $thumb is an image object. `echo ''.$thumb->getThumb('album').'
'`Now for one more small problem:
When I render the tumbnails using printCustomAlbumThumbImage it's setting the height and width attributes of the `` to the value of cropx and cropy. In template_functions.php it looks like it's is choosing whichever is higher, width or cropx, and then setting the width="" attribute to that (???). Since cropx is relative to the original image it's going to be bigger than the thumb size. So I get thumbnails that are resized using the height/width attributes to something like 1450 x 1450 (or whatever the size of the original image was).
I can fix this by changing max to min or just removing the $settings variable from the ``. It is generating the thumbnails correctly.
Here's my current function:
`
<?php<br />
$thumb = $_zp_current_album->getAlbumThumbImage();
if ($thumb->getWidth() >= $thumb->getHeight()) {
$ch = $thumb->getHeight();
$cx = ($thumb->getWidth()/2) - ($ch/2);
printCustomAlbumThumbImage(getImageTitle(), null, 180, 180, $ch, $ch, $cx, null);
} else {
$cw = $thumb->getWidth();
printCustomAlbumThumbImage(getImageTitle(), null, 180, 180, $cw, $cw, null, 50);
}
?>
`