Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: devel

Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org

 

 

Bricolage devel RSS feed   Index | Next | Previous | View Threaded


phillip at communitybandwidth

Oct 1, 2008, 11:38 AM

Post #1 of 8 (6195 views)
Permalink
Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org

Just ran across this looking for a solution to make a quick thumbnail
for PDFs:
http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-PDF-1.11/lib/Image/Magick/Thumbnail/PDF.pm

I was going to use this at the "front end," e.g.: so web visitors
could see little thumbs of the PDFs output by Bricolage to a
"downloads" section ... but thought it might actually be useful to
have little thumbnails **in** Bricolage too.

Thoughts?

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth
http://www.communitybandwidth.ca


david at kineticode

Oct 1, 2008, 11:50 AM

Post #2 of 8 (5999 views)
Permalink
Re: Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org [In reply to]

On Oct 1, 2008, at 11:38, Phillip Smith wrote:

> Just ran across this looking for a solution to make a quick
> thumbnail for PDFs:
> http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-PDF-1.11/lib/Image/Magick/Thumbnail/PDF.pm
>
> I was going to use this at the "front end," e.g.: so web visitors
> could see little thumbs of the PDFs output by Bricolage to a
> "downloads" section ... but thought it might actually be useful to
> have little thumbnails **in** Bricolage too.

Sure. You'd have to somehow distinguish PDFs and re-dispatch to a
function that did that when thumbnail_uri() was called. Patch to trunk?

FWIW, IIRC, Image::Magick is a bitch to compile. Now that we're
finally read of Math::Pari, I'm leary of adding something else that's
a PITA. That's why we use Imager for image thumbnails rather than
Image::Magick.

Best,

David


phillip at communitybandwidth

Oct 1, 2008, 12:43 PM

Post #3 of 8 (5999 views)
Permalink
Re: Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org [In reply to]

On 1-Oct-08, at 2:50 PM, David E. Wheeler wrote:

> On Oct 1, 2008, at 11:38, Phillip Smith wrote:
>
>> Just ran across this looking for a solution to make a quick
>> thumbnail for PDFs:
>> http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-PDF-1.11/lib/Image/Magick/Thumbnail/PDF.pm
>>
>> I was going to use this at the "front end," e.g.: so web visitors
>> could see little thumbs of the PDFs output by Bricolage to a
>> "downloads" section ... but thought it might actually be useful to
>> have little thumbnails **in** Bricolage too.
>
> Sure. You'd have to somehow distinguish PDFs and re-dispatch to a
> function that did that when thumbnail_uri() was called. Patch to
> trunk?
>
> FWIW, IIRC, Image::Magick is a bitch to compile. Now that we're
> finally read of Math::Pari, I'm leary of adding something else
> that's a PITA. That's why we use Imager for image thumbnails rather
> than Image::Magick.

Good point. :-(

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth
http://www.communitybandwidth.ca


bret at pectopah

Oct 1, 2008, 12:52 PM

Post #4 of 8 (6006 views)
Permalink
Re: Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org [In reply to]

Hi everybody,

If I recall correctly, Image::Magick was actually pretty easy last time
I tried it.

Or maybe it was that the Gentoo package installed without complaint, and
so did the Ubuntu one. Come to think of it, I'm not sure I've ever
compiled it.

Anyway, my own personal makefile chops = 0, but I've used and installed
Image::Magick for use in Bricolage templates on at least a couple of
platforms without any trouble. So let me personally encourace Phillip to
steam ahead with the plan...

Cheers,

Bret


On Wed, 2008-10-01 at 15:43 -0400, Phillip Smith wrote:
> On 1-Oct-08, at 2:50 PM, David E. Wheeler wrote:
>
> > On Oct 1, 2008, at 11:38, Phillip Smith wrote:
> >
> >> Just ran across this looking for a solution to make a quick
> >> thumbnail for PDFs:
> >> http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-PDF-1.11/lib/Image/Magick/Thumbnail/PDF.pm
> >>
> >> I was going to use this at the "front end," e.g.: so web visitors
> >> could see little thumbs of the PDFs output by Bricolage to a
> >> "downloads" section ... but thought it might actually be useful to
> >> have little thumbnails **in** Bricolage too.
> >
> > Sure. You'd have to somehow distinguish PDFs and re-dispatch to a
> > function that did that when thumbnail_uri() was called. Patch to
> > trunk?
> >
> > FWIW, IIRC, Image::Magick is a bitch to compile. Now that we're
> > finally read of Math::Pari, I'm leary of adding something else
> > that's a PITA. That's why we use Imager for image thumbnails rather
> > than Image::Magick.
>
> Good point. :-(
>
> --
> Phillip Smith,
> Simplifier of Technology
> Community Bandwidth
> http://www.communitybandwidth.ca
>
>
>
>
--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com


bharder at methodlogic

Oct 1, 2008, 7:04 PM

Post #5 of 8 (6017 views)
Permalink
Re: Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org [In reply to]

On Wed, Oct 01, 2008 at 03:52:32PM -0400, Bret Dawson wrote:
> Hi everybody,
>
> If I recall correctly, Image::Magick was actually pretty easy last time
> I tried it.
>
> Or maybe it was that the Gentoo package installed without complaint, and
> so did the Ubuntu one. Come to think of it, I'm not sure I've ever
> compiled it.
>
> Anyway, my own personal makefile chops = 0, but I've used and installed
> Image::Magick for use in Bricolage templates on at least a couple of
> platforms without any trouble. So let me personally encourace Phillip to
> steam ahead with the plan...

I've never had issues compiling either, but fwiw, Image::Magick is nothing but an OO wrapper than shells-out to the usual ImageMagick binaries anyway -- considering imager is already installed, and the feature that's being discussed is only resizing PDFs, it may be worth considering just exec()ing, until there's a more compelling reason to drag the whole works in.

$0.02,

-bch


> Cheers,
>
> Bret
>
>
> On Wed, 2008-10-01 at 15:43 -0400, Phillip Smith wrote:
> > On 1-Oct-08, at 2:50 PM, David E. Wheeler wrote:
> >
> > > On Oct 1, 2008, at 11:38, Phillip Smith wrote:
> > >
> > >> Just ran across this looking for a solution to make a quick
> > >> thumbnail for PDFs:
> > >> http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-PDF-1.11/lib/Image/Magick/Thumbnail/PDF.pm
> > >>
> > >> I was going to use this at the "front end," e.g.: so web visitors
> > >> could see little thumbs of the PDFs output by Bricolage to a
> > >> "downloads" section ... but thought it might actually be useful to
> > >> have little thumbnails **in** Bricolage too.
> > >
> > > Sure. You'd have to somehow distinguish PDFs and re-dispatch to a
> > > function that did that when thumbnail_uri() was called. Patch to
> > > trunk?
> > >
> > > FWIW, IIRC, Image::Magick is a bitch to compile. Now that we're
> > > finally read of Math::Pari, I'm leary of adding something else
> > > that's a PITA. That's why we use Imager for image thumbnails rather
> > > than Image::Magick.
> >
> > Good point. :-(
> >
> > --
> > Phillip Smith,
> > Simplifier of Technology
> > Community Bandwidth
> > http://www.communitybandwidth.ca
> >
> >
> >
> >
> --
> Bret Dawson
> Producer
> Pectopah Productions Inc.
> (416) 895-7635
> bret [at] pectopah
> www.pectopah.com
>

--

Brad Harder,
Method Logic Digital Consulting
http://www.methodlogic.net


phillip at communitybandwidth

Oct 2, 2008, 10:57 AM

Post #6 of 8 (6003 views)
Permalink
Re: Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org [In reply to]

On 1-Oct-08, at 10:04 PM, bharder wrote:

> On Wed, Oct 01, 2008 at 03:52:32PM -0400, Bret Dawson wrote:
>> Hi everybody,
>>
>> If I recall correctly, Image::Magick was actually pretty easy last
>> time
>> I tried it.
>>
>> Or maybe it was that the Gentoo package installed without
>> complaint, and
>> so did the Ubuntu one. Come to think of it, I'm not sure I've ever
>> compiled it.
>>
>> Anyway, my own personal makefile chops = 0, but I've used and
>> installed
>> Image::Magick for use in Bricolage templates on at least a couple of
>> platforms without any trouble. So let me personally encourace
>> Phillip to
>> steam ahead with the plan...
>
> I've never had issues compiling either, but fwiw, Image::Magick is
> nothing but an OO wrapper than shells-out to the usual ImageMagick
> binaries anyway -- considering imager is already installed, and the
> feature that's being discussed is only resizing PDFs

Not re-sizing per se, but converting the first page of the PDF to a
small thumbnail image, e.g.: a jpg, gif, or png.

Ideas on how to do that without using Image::Magick::Thumbnail::PDF ?

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth
http://www.communitybandwidth.ca


bret at pectopah

Oct 2, 2008, 11:27 AM

Post #7 of 8 (5983 views)
Permalink
Re: Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org [In reply to]

We actually have a template that does that now. It only uses
Image::Magick, not the PDF extension, but the process is pretty simple.

You can simply read in the first page of the PDF and then resize it and
output a JPG. Here's a snippet:


#create a thumbnail of the first page of the pdf 75 pixels wide
my $image;
$image = new Image::Magick;
$image->Read($pdfFile."[0]");
$image->Thumbnail('75');
$image->Set(colorspace=>'RGB');
$image->Write($tmpFile);
undef $image;

#now upload our new image
my $fh;
open($fh, "<$tmpFile");
$newrelmedia->upload_file($fh, $jpgFileName);
close ($fh);


Again, this requires Image::Magick. But like I was saying I'm a fan.

Cheers,

Bret

On Thu, 2008-10-02 at 13:57 -0400, Phillip Smith wrote:
> On 1-Oct-08, at 10:04 PM, bharder wrote:
>
> > On Wed, Oct 01, 2008 at 03:52:32PM -0400, Bret Dawson wrote:
> >> Hi everybody,
> >>
> >> If I recall correctly, Image::Magick was actually pretty easy last
> >> time
> >> I tried it.
> >>
> >> Or maybe it was that the Gentoo package installed without
> >> complaint, and
> >> so did the Ubuntu one. Come to think of it, I'm not sure I've ever
> >> compiled it.
> >>
> >> Anyway, my own personal makefile chops = 0, but I've used and
> >> installed
> >> Image::Magick for use in Bricolage templates on at least a couple of
> >> platforms without any trouble. So let me personally encourace
> >> Phillip to
> >> steam ahead with the plan...
> >
> > I've never had issues compiling either, but fwiw, Image::Magick is
> > nothing but an OO wrapper than shells-out to the usual ImageMagick
> > binaries anyway -- considering imager is already installed, and the
> > feature that's being discussed is only resizing PDFs
>
> Not re-sizing per se, but converting the first page of the PDF to a
> small thumbnail image, e.g.: a jpg, gif, or png.
>
> Ideas on how to do that without using Image::Magick::Thumbnail::PDF ?
>
> --
> Phillip Smith,
> Simplifier of Technology
> Community Bandwidth
> http://www.communitybandwidth.ca
>
>
>
>
--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com


phillip at communitybandwidth

Oct 6, 2008, 7:03 AM

Post #8 of 8 (5977 views)
Permalink
Re: Image::Magick::Thumbnail::PDF - make thumbnail of a page in a pdf document - search.cpan.org [In reply to]

Very cool. Many thanks. Going to give that a go!

:-)

On 2-Oct-08, at 2:27 PM, Bret Dawson wrote:

> We actually have a template that does that now. It only uses
> Image::Magick, not the PDF extension, but the process is pretty
> simple.
>
> You can simply read in the first page of the PDF and then resize it
> and
> output a JPG. Here's a snippet:
>
>
> #create a thumbnail of the first page of the pdf 75 pixels wide
> my $image;
> $image = new Image::Magick;
> $image->Read($pdfFile."[0]");
> $image->Thumbnail('75');
> $image->Set(colorspace=>'RGB');
> $image->Write($tmpFile);
> undef $image;
>
> #now upload our new image
> my $fh;
> open($fh, "<$tmpFile");
> $newrelmedia->upload_file($fh, $jpgFileName);
> close ($fh);
>
>
> Again, this requires Image::Magick. But like I was saying I'm a fan.
>
> Cheers,
>
> Bret
>
> On Thu, 2008-10-02 at 13:57 -0400, Phillip Smith wrote:
>> On 1-Oct-08, at 10:04 PM, bharder wrote:
>>
>>> On Wed, Oct 01, 2008 at 03:52:32PM -0400, Bret Dawson wrote:
>>>> Hi everybody,
>>>>
>>>> If I recall correctly, Image::Magick was actually pretty easy last
>>>> time
>>>> I tried it.
>>>>
>>>> Or maybe it was that the Gentoo package installed without
>>>> complaint, and
>>>> so did the Ubuntu one. Come to think of it, I'm not sure I've ever
>>>> compiled it.
>>>>
>>>> Anyway, my own personal makefile chops = 0, but I've used and
>>>> installed
>>>> Image::Magick for use in Bricolage templates on at least a couple
>>>> of
>>>> platforms without any trouble. So let me personally encourace
>>>> Phillip to
>>>> steam ahead with the plan...
>>>
>>> I've never had issues compiling either, but fwiw, Image::Magick is
>>> nothing but an OO wrapper than shells-out to the usual ImageMagick
>>> binaries anyway -- considering imager is already installed, and the
>>> feature that's being discussed is only resizing PDFs
>>
>> Not re-sizing per se, but converting the first page of the PDF to a
>> small thumbnail image, e.g.: a jpg, gif, or png.
>>
>> Ideas on how to do that without using
>> Image::Magick::Thumbnail::PDF ?
>>
>> --
>> Phillip Smith,
>> Simplifier of Technology
>> Community Bandwidth
>> http://www.communitybandwidth.ca
>>
>>
>>
>>
> --
> Bret Dawson
> Producer
> Pectopah Productions Inc.
> (416) 895-7635
> bret [at] pectopah
> www.pectopah.com
>

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth
http://www.communitybandwidth.ca

Bricolage devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.