hi,
When i try and create a thumb with printCustomAlbumThumbImage to be landscape from a portrait image the resulting thumb is distorted.
To me the function should always shrink any image to fit the width of the thumb and then cut off from the height to match the height
I am trying to create a 200x113 thumb of a 800x600 image without cropping on the width
Is there a quick solution for this?
Comments
Giving width,height,cropw,croph to the custom albumthumb function does not distorted but it also does zoom into the picture.
Have a look at this example:
www.bregler.net/backup/view.php
I also discovered it to be a general problem with both landscape and portrait pictures
Ideas anyone?
How do i activate DEBUG_IMAGE for logging?
If you didn't think of doing a search on that identifier, maybe you should consider if you will be able to understand the rest of the code....
I did a full text search. xp must have missed it. I will try again. Thanks
people who show interest in your creation you could as well write something
positive like just answer the (daft) question:
define('DEBUG_IMAGE', false); -> functions-basic.php l 17
so that it can be found through the search function
I really appreciate your work !
It all boils down into the cacheImage function in functions-image.php.
The bug sits in the cropping logic after line 238.
The distortion is the result of incorrectly calculated $cw & $ch in there.
This bug can somehow be worked arround by setting the cropping width&height equal to the thumb width&height. But this then results into the described 'zoom' effect through the way the native php function 'imagecopyresampled' works.
..the disproportinal measure of the source & destination rectangle leads to this.
My question know is why the cropwidth & cropheight are handed into the core function from ZP at all? In my eyes it would make more sense to calculate the cropwidth & cropheight required on the fly instead by simply comparing image dimensions to desired thumb dimension and calculate the best fitting thumb that way ?
Is there a specific reason cacheImage works this way for other uses ?
Is the 'zoomed' thumb image considered a feature ?
Would anyone be interested in me rewriting the cacheImage function to minimize crop loss ?
or may this even be a specific behaviour of my GD lib (v2.0.34) on my webserver ?
What do you mean by "on the fly" calcualtions? I would take this to mean as the script loads, which is exactly what happens.
Anyway, maybe you should share your trace information and how you are setting up the image. Then perhaps we can see what is going wrong.
printCustomAlbumThumbImage($gallery_title,'','200','113','200','113',Null,Null,'','');
on 500x336 landscape image creates an overly cropped but portrait pictures are not distorted. However the portrait pictures 336x210 get distorted if I use
printCustomAlbumThumbImage($gallery_title,'','200','113','','',Null,Null,'','');
needless to say that I want 200x113 thumb no matter the real underlying image
Is there a way to achieve this through tis function without touching the code ?
check these example: http://www.bregler.net/backup/view.php
What I mean with on the fly is why the $cropw, $croph are there at all ?
the only thing it leads to in my eyes is distortion. I think they should be calculated
automatically ($cw = round($w*$ir)).
Seems what you desire is pretty much what is done by the Efferevescence+ theme:
`printCustomAlbumThumbImage($annotate, null, 180, null, 180, 80);`
i'm not certain why your first call overly cropped the image. Have to look into that. The second one, though said "create a 200x113 image from the original" (no cropping). Naturally that would be a distorted image.
www.bregler.net/backup/log.txt
I quickly configured the examples here : http://www.dev.bregler.net/gallery/
but still I get the over cropped result.
compare: http://www.dev.bregler.net/gallery/2000/Wolf_und_Hilal__Hamburg__2000__pbh.jpg.php
to the thumb at http://www.dev.bregler.net/gallery/
the problem is exactly the same as decribed in my debug log
$cw=368, $ch=208 are wrong !
it should be $cw=500, $ch=282; ($ch=500*113/200)
Which is a bug I believe to be in the cacheImage function
for myself, but I put this forward to go in as a bug-fix as it adds flexability
the current code is not ready to create portrait thumbs from landscape images and vice versa
to do this
$cr = min($w, $h)/$ts; (line 135)
has to be replaced with
if ($neww > $newh) $cr=$w/$ts; else $cr=$h/$ts;
What do the local developer heros say?
I am not trying to make a point here, as I said it is solved for myself so I am fine. I am just trying to help making ZP better.
I am not sure I understand you saying that the code change has no effect?
So when you create a cropped thumb out of a landscape image you do not get the zoom?
Have you had a look at the log file?
At the moment the min() function multiplies the image height with the crop ratio to calculate the crop width. $cw.
Btw I also would like to mention that most thumbs look better when $cy is calculated to be off center towards the top just like when mounting real pictures.
line 282 ....divide by 3 instead of 2...
This has to do with the law of thirds. A basic design principle most photos follow.
Your suggestion to use the law of thirds is a good one. Hopefully no one will object to the change in behavior.
for both an 500x336 and an 233x336 crop calculation to come by a 200x113 tumb
Maybe that helps you to repeat the issue I had
I have change the $cy in my custom function to "/3" and I think it looks a lot better.
So for everybody who is not familiar with the law of thirds here is some reading:
http://www.silverlight.co.uk/tutorials/compose_expose/thirds.html
A lecturer of mine used to say that you can break every rule if you know them and know why; I am sure there is plenty of exceptions which are still great pictures but especially in framing and mounting it is almost certainly used:
http://en.wikipedia.org/wiki/Headroom_(photographic_framing)
I would vote for this go into the next release