Tuesday, June 26, 2012

Tuesday, June 19, 2012

[php]pdf files to thumbnail PHP

godaddy and imagemagick make me unhappy..

[php]pdf files to thumbnail PHP Server Side Scripting forum at WebmasterWorld

"Hi,
i want to generate a previeiw´tghumbnail of a pdf file.
so far i figured out that ghostwrite and imagemagick is needed. so i asked my hoster to install it.

i found a script snippet that should perform this: 
$filename = "foo";
$file1 = "/Library/WebServer/Documents/polo/pdf/$filename.pdf";
$file2 = "/Library/WebServer/Documents/polo/jpg/$filename.jpg";
$result1 = @exec("/sw/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeg
-sOutputFile=$file2 $file1 2>&1");
$result2 = @exec("/usr/local/bin/convert -resize 120x120 $file2
$file2 2>&1");

i altered this to this 
$filename = "norden";
$file1 = "$filename.pdf";
$file2 = "$filename.jpg";
$result1 = exec("/usr/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeg -sOutputFile=$file2 $file1 2>&1");
$result2 = exec("/usr/bin/convert -resize 120x120 $file2 $file2 2>&1");
if($result1 && $result2)
{echo "something happend";}

i made a directory with chmod 777 and loaded this script and a pdf called norden.pdf up. when i call this script
"something happens " appears but no jpg is created...."






Create Thumbnails of PDF files in PHP, Java, Perl, or Ruby? - Yahoo! Answers

Create Thumbnails of PDF files in PHP, Java, Perl, or Ruby? - Yahoo! Answers


Best Answer - Chosen by Asker

It is possible in PHP, although you were right, you need a few libraries.

ImageMagic:
http://us3.php.net/imagick

Ghostscript:
http://sourceforge.net/projects/ghostscr…

Then, this code will get your thumbnail:

<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
?>

Haven't tried it myself, but seems like it would work

Source(s):

  • 1 person rated this as good
Asker's Rating:
3 out of 5
Asker's Comment:
Thanks I got it figured out, I just ended up pointing a new variable ($pdf) to the array item ($pdf_file_list[23]) and then set imageMagick to just convert the first page which is the cover by doing this: $im->readImage( 'library/'.$pdf.'[0]'); The code you gave me did work though.




Sunday, June 17, 2012

Wednesday, June 13, 2012

WORST BEER EVER: Mountain Crest Classic - Minhas Craft [read: CRAP] Brewery - Monroe, WI - BeerAdvocate

WORST BEER EVER.. It will clean you out, thoroughly!
Mountain Crest Classic - Minhas Craft Brewery - Monroe, WI - BeerAdvocate

Mountain Crest Classic

 

BA SCORE
N/A

-
8 Reviews
THE BROS
N/A

-
send 'em beer »
rAvg: 2.64
pDev: 20.83%
High: 3.1
Low: 1.28

Ratings [?]
Mountain Crest ClassicMountain Crest Classic

Displayed for educational use only; do not reuse.
Brewed by:
Minhas Craft Brewery visit their website
WisconsinUnited States

Style | ABV
American Adjunct Lager |  5.50% ABV


Notes:
Year-round. Serving types had: can (8).

No other notes at this time.

Write a review and rate this beer : Mountain Crest Classic Review This Beer | 

View:  Beers  (65) |  Events  (0)

Reviews

Sort by:  Latest | High | Low | Top Reviewers

WastingFreetime



1.28/5  rDev -51.5%
look: 2.5 | smell: 1 | taste: 1 | feel: 2 | overall: 1.5

Reviewed from notes.

A. Transparent pee-yellow with a short lived foam collar, no real lacing at all to speak of.

S. Smells like apple/pear juice mixed with simple syrup sweetener from a bar dispenser.

T. Rotting potatoes, sugary sweetness combined with acidic vomitous bile, with a very long extended rusty metal finish. Wow. If it were possible to rate a zero out of five I would without hesitation. Seriously, a very pervasive rotten potatoes flavor either speaks for an infected can or a very terrible beer.

M. Light, thin and watery, but not quite carbonated enough to clear the metallic / acid haze from my mouth.

Oh dear lord, this one was really quite terrible. I recommend staying the hell away from this "beer". Even if I had happened to get some kind of infected can, I am not willing to subject myself to the contents of another on the off-chance that it might be better, that was how bad it was. It is just not worth the risk.

Serving type: can

Reviewed on: 03-17-2012 22:19:29id: 1760944