I am trying to upload both a full pdf and a jpg thumbnail of the first page to a MySQL data base but I am having no luck. I am using the following sub routine:
sub read_image_file { my $fh = shift; # filename/file handle my $img = new Image::Magick; my ($full, $thumb, $err); # read full-size image directly from upload file (read ($fh, $full, -s $fh) == -s $fh) or error ("Can't read image file: $!"); # produce jpg from pdf (this is where i'm lost because i get a can +'t convert error) # produce thumbnail from full-size image $err = $img->BlobToImage ($full); error ("Can't convert image data: $err") if $err; $err = $img->Scale (geometry => "150x194"); error ("Can't scale image file: $err") if $err; $thumb = $img->ImageToBlob (); return ($full, $thumb); }
This works ok with images but not with PDFs. My guess is I need to do some kind of conversion to the PDF but can figure out how. Thanks in advance for any help. Rich

In reply to PDF to JPG for MySQL by rich731

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.