The Square Thumbnails Module has the priority hard coded to 10 in
$ret = GalleryCoreApi::registerToolkitOperation('SquareThumb', $mimeTypes, 'thumbnail',
array(array('type' => 'int', 'description' => $gallery->i18n('target size'))),
$gallery->i18n('Create square thumbnail'), '', 10);
I changed it to
list ($ret, $priority) = GalleryCoreApi::getMaximumManagedToolkitPriority();
if ($ret->isError()) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
$priority++;
// skip
$ret = GalleryCoreApi::registerToolkitOperation('SquareThumb', $mimeTypes, 'thumbnail',
array(array('type' => 'int', 'description' => $gallery->i18n('target size'))),
$gallery->i18n('Create square thumbnail'), '', $priority);
and now the module's priority is manageable in ToolKit Priority menu.
Now we can control weither to use square thumbnails or not from the ToolKit Priority menu. I would like to know if this is the right way to have to options into ToolKit Priority menu.
Another thing that I noticed:
After enabling Thumbnails Module and set the "Recreate thumbnails" in an album, the first refresh of the page will not have the right image width and height ratio. The picture is croped into square but the image showed on the webpage still has the dimension from previous thumbnail. The second refresh of the page will fix it.
Thank you for the great work!
Posts: 10
FYI, I am unsing 2004-11-04's dailysnap shot.
Just tried to reinstall the gallery again, this time I activated the Square Tumbnails Module from the installer. In gallery module manager "Square Thumbnails Manager" showed inactived.When I try to active the "Square Thumbnails Manager", gallery returned
EDITED: Sorry, the one that is not activated was not "Square Thumbnails Manager", it was "Thumbnail Manager"
Tried to upload some picture, and theire thumb nails are square.
P.S.
I tried to reporduce this several times, if you go to the gallery modules manager right after the installation and try to activate it, it will produce this error. But after several tries ( or maybe several minutes ) it will active fine.
Posts: 10
Found some weird behavior after the above code modification.
If the Toolkit Priority is
Then the correct thumbnail will not show, instead it shows something look like an broken glass.
If I have Gd or NetPBM take ImageMagick's priority then it seems to work fine.
Can someone give me a hint?
Thank you very much.
Posts: 8601
The thumbnail manager error has been reported many times, but no one has gotten any additional debug output to add to this bug.. sounds like you have some coding ability, so maybe you can help here?
Why do you want to add square thumbnaills to the toolkit priority view? You can turn it on/off by activating/deactivating the module in site admin / modules.
Posts: 10
Hi, mindless
I would like to help. Can you give me some directions? Thanks.
I was playing with the Square Thumbnails module to get familiar with the gallery2 model system. I wanted to add a JpegTran module to gallery2 so that it can do lossless JPEG transformation.
Posts: 10
I found that it is not necessary to have the above code modification to broke the square thumbnail. Install only the ImageMagick Graphics Tollkit and enable Square Thumbnails will do.
The image will not be croped properly.
I tried to look at the source code, but have no idea at all.
Currently still trying to understand the structure of g2.
Posts: 8601
Here's what I wrote in the bug:
put some var_dump code around those lines to figure out why it doesn't think GalleryGroup is registered.. thanks for any help you can provide.
What are the steps to reproduce the broken square thumbnail? sounds like you have a cropped thumbnail..
Posts: 10
Steps to reproduce this:
1. fresh install of 2004-11-04's snap shot (2004-11-05 won't install for me)
2. select ImageMagick as the only Graphics Toolkit
3. select Square Thumbnails module
4. upload picture
5. get weird thumbnail or no thumbnail at all (get a broken blue glass).
FreeBSD 5.3
apache-2.0.52_3
php4-4.3.9
ImageMagick-6.0.6.2
here is a sample installation:
http://mjbsd.mjwu.net/~michael/gallery2-bk/main.php
Thank you.
Posts: 7994
I think that this is an ImageMagick issue, but I'm not sure. Would it be possible to get ssh access to your box so that we can try to reproduce the issue directly? That'll save a lot of back and forth in the forums...
Posts: 7994
mingjuwu gave me ssh access and I reproduced and fixed the bug with activating the thumbnail module. Thanks, minjuwu!
As for the ImageMagick issue, I can reproduce this on my box. With only the square thumbnail module and ImageMagick activated, I uploaded a 710x634 JPEG. The operations that it ran were:
convert -quality 75 -crop 634x634+38+0 -geometry 150x150 FILE1 FILE2
I wind up with a 112x134 JPG. If I break it up into two operations:
then I wind up with a 150x150 JPG. This is with ImageMagick 6.0.6 11/29/04. It works fine with NetPBM. Didn't test GD.
mindless, it seems like this might be caused by your "smush imagemagick down to 1 operation" optimization?
Posts: 8601
does anyone understand imagemagick's command line parameters? i already changed it to remove the -size parameter when a -crop is involved, as that was causing problems, but now with im6 it's even having trouble with -geometry? if anyone knows the proper parameters i can try to fix this..
Posts: 7994
Argh. I haven't looked at the context code, yet. But from what I understand, it would be possible to split off the -geometry operation into a separate convert call if we want, right? (as a workaround to this problem for now).
Posts: 8601
any step along the way can choose to exec something rather than queueing parameters... so the crop can call convert to just crop and then the subsequent thumbnail operation will have nothing to do but resize with another convert call.. but come on, is there no correct set of parameters to crop and resize in one call? is this problem im6 specific?
Posts: 8601
i filed a bug so we don't forget about this.
Posts: 113
So in theory, the following should work for crop + resize:
convert -size 150x120 bigimage.jpg -crop 120x120+30+0 -resize 120x120 +profile "*" thumbnail.jpg
I think the Geometry problem has to do with the default behaviour of -geometry:
Posts: 328
CSpotkill, problem is, is isn't consistent on all imagemagick versions. We have no problem with IM4 through 5.x, but IM6 it just doesn't work.
Have you managed to crop and resize in one step with Imagemagick 6? The above command line on IM 6.0.7 ignores the crop specifications.
And the -resize parameter isn't known in IM<6.x.
Posts: 113
Well, here's the results from a little experimentation with ImageMagick 6.1.6 Q8 on Windows:
convert -quality 75 -crop 200x200+0+0 -geometry 150x160 images\ImageMagick.jpg images\logo.jpg
convert -quality 75 -crop 200x200+0+0 -geometry 150x160! images\ImageMagick.jpg images\logo2.jpg
logo.jpg - 150x155
logo2.jpg - 150x160
Notice the difference? As I wrote before this ...
Posts: 8601
how does that test apply to the problem reported here? i don't think we have any need of that ! thing
Posts: 113
Uh. The problem was that it wasn't resizing properly. It only resized properly when the command was split in two, putting the -geometry switch as another command ...
I was showing how to resize and crop in one step, with the desired output size.
Posts: 7994
I didn't know about the exclamation mark modifier. That's cool. It didn't work for me, though:
The result of the first operation should have given the transitional image a 1:1 aspect ratio, but both times it wound up with the wrong one (83:100 and 74:100). My guess is that ImageMagick isn't tracking the fact that the crop changed the aspect ratio, and is adjusting for the original aspect ratio (though I haven't tried to hard to make the math work out on that hypothesis).
I tried using a subsection instead:
No joy. I filed a bug about it in their forums. Let's see what happens.
Posts: 113
Try convert -crop 634x634+38+0 ALIVE.JPG out.jpg -geometry 150x150! ALIVE.JPG out.jpg
It's more of a workaround than doing it all in one go, but it's one execution, still ...
Posts: 7994
No joy. Without the exclamation point:
Still no joy. Without the second ALIVE.JPG:
It doesn't seem to like the out.jpg argument in the middle...
Posts: 118
Any news on this subject? Gallery 2 with square thumbnails and ImageMagick does not seem to work, still...
Posts: 7994
Unfortunately, no news here. It's still open as a bug and we'll get to it when we can...
Posts: 63
It works always with the "BuildAllDerivatives.php" script.
(Linux: Debian Woody + Imagemagick)
Posts: 118
But ImageMagick version (and apparently its syntax) changed since Woody, that's the problem...
Posts: 7994
I've just submitted a fix for this. I stopped the imagemagick module from pipelining -convert and -geometry so that we now use a temporary file; this fixes the problem with ImageMagick 6.1.x (at the expense of being a little less efficient when generating cropped thumbnails).
Posts: 118
Great, I'll test it later this day!