Closed (won't fix)
Project:
ImageCache Actions
Version:
6.x-1.6
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 Sep 2009 at 07:49 UTC
Updated:
18 Mar 2016 at 18:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dman commentedI know that is maybe a problem in imageMagick, but with GD, I'd think that most of the processing is on the image object in memory.
This means I would expect you could delete that image yourself in your custom code. Later imagecache actions will not load from file again.
Or you can add another customaction at the end of the process before imagecache returns.
Or maybe I'm not sure exactly what the problem is. Can you post the code?
Comment #2
anrikun commentedYou guessed well: I'm using ImageMagick!
Actually, I've modified imagecache module itself a bit so that I can use ImageMagick to convert the first 2 pages of a PDF file into a "double" thumbnail.
(See http://drupal.org/node/460132)
I use the following custom action to generate the thumbnail.
My code might not be perfect but it works, with the only problem that the temporary image $img3 ending with ".pdf.jpg" is not deleted:
As you can see, I use GD to concat the 2 thumbnails into one. Maybe if I could do this with ImageImagick I wouldn't need a temporary image anymore...
Comment #3
dman commentedI see what you are doing. Makes sense in a sequential way.
I'm not too sure how imageapi works with imagemagick... BUT I think that if you were to finish with
$image = imageapi_image_open($file);instead of just setting image->source then the processing could continue and you'd be able to discard that temp image then...In GD anyway. Hm, no in imagemagick you do still need that file around until the very end. Tricky.
In imageapi_imagemagick, you concatenate instructions onto the
$image->ops[]array, and they all get run at the end. I'm sure somehow with imagemagick pipeline you can insert the right ops that would get the result, but damned if I know how that works. Like You, I'd break it into steps I can understand.I can only say I'd do it all in GD - because then the processing is done in memory we can pass around. You can STILL use the imagemagick pdf convert in your custom action, but you'd be able to clean up afterwards and carry on in GD.
Comment #4
anrikun commentedFirst I had tried to do it that way, but convert doesn't seem to work if ImageMagick is not selected as imageapi's toolkit.
As it's written in http://drupal.org/node/460132: Don't forget to change your ImageAPI to Imagemagick
:-(
Comment #5
dman commentedI would have guessed that's because you call '_imageapi_imagemagick_convert' which needs the include available. ... although the code seems to be there if the module is just enabled.
Did you re-open the file after imagemagick was done with it? You'd need to do
$image = imageapi_image_open($file);before going back to GD or the GD pipeline will still have a handle on the old image. Just changing the ->file is not enough once the process has started.Comment #6
anrikun commentedHi again dman!
I've finally managed to do what I wanted and what you advised me to:
- use _imageapi_imagemagick_convert while GD is the default toolkit
- use GD after PDF conversion so that there's no useless temporary file remaining
But $image = imageapi_image_open($file); can't be used as it breaks the reference to the original $image object that is passed between actions.
I've also had to patch imagecache.module again so that it doesn't complain about the PDF source file and the fact that I use ImageMagick while GD is the selected toolkit.
If someone is interested in this, I can post the code, but I don't know if this issue is the best place for that?
Comment #7
anrikun commentedComment #8
dubs commentedHi Anrikun,
I would be interested to see the code - I need to do this too and it sounds like you've got it working.
Thanks,
Dubs
Comment #9
anrikun commentedCan you please tell me what kind of thumbnail you want to generate? 1 page, 2 pages?
See an example of what my code achieves:
http://www.lelieududesign.com/en/sociology-watch
(you want be able to download PDFs but at least, you'll be able to see thumbnails!)
It is what you need?
Comment #10
dubs commentedHi again,
That's perfect - either one page or 2 pages is fine. I can probably adapt the code to suit as I'm not 100% sure whether to just use the first page for now.
Thanks again for offering to post your code....
Dubs
Comment #11
anrikun commentedI've posted everything here:
http://drupal.org/node/641372
Please post a comment if some of the explanations are not clear and... tell me if it works :-)
(the patch below is to use during the tutorial)
Comment #12
magnus commentedComment #13
fietserwinD6 EOL. This module's D6 issues already haven't received any attention for over a year. Closing them all unconditionally now.