Help with converting eBook PDF.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Kevii
Posts: 1
Joined: 2011-01-10T21:43:10-07:00
Authentication code: 8675308

Help with converting eBook PDF.

Post by Kevii »

Hi, Sorry this will probably be a dumb question but I have a script and I am not sure how I am supposed to run it. The instructions were:

# Rename the PDF file to "csource.PDF" and run this. It will split the file up into single page PNG files which are easier to read on the screen. You can zip them together as a CBZ file and use CDisplay (but be sure to disable thumbnail generation in CDisplay (Options/Preferences/Configuration) or it will run very slow. It file will be bigger but much easier to read.
# This script needs ActivePerl, ImageMagick and Ghostscript (change path as required)

$pages = 1317;

for ($i=1; $i<=$pages; $i++)
{
$wide_fn = "chem" . $i . ".png";
$pp1_fn = sprintf("pp%06d.png", (($i-1)*2 + 0 + 1));
$pp2_fn = sprintf("pp%06d.png", (($i-1)*2 + 1 + 1));

print "**** Page " . $i . "\n";

if (! -e $wide_fn)
{
print "generating Page " . $i . "\n";

$cmd = "C:\\Progra~1\\gs\\gs9.00\\bin\\gswin32c.exe -dNOPAUSE -dBATCH -r300 -dFirstPage=" . $i . " -dLastPage=" . $i

. " -sDEVICE=png16m -sOutputFile=" . $wide_fn . " " csource.PDF";
system $cmd;
}

if (! -e $pp1_fn)
{
print "converting Left Page " . $i . " to " . $pp1_fn . "\n";

$cmd = "convert " . $wide_fn . " -crop 2584x3104+19+79 -resize 1024 " . $pp1_fn;
system $cmd;
}

if (! -e $pp2_fn)
{
print "converting Right Page " . $i . " to " . $pp2_fn . "\n";

$cmd = "convert " . $wide_fn . " -crop 2584x3104+2606+79 -resize 1024 " . $pp2_fn;
system $cmd;
}
}

Am I supposed to make this a pl file and try to run? That doesnt work. Where should I put the csource.pdf? Sort of lost.

Thanks for any help.
Post Reply