![]() |
#1 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: May 2008
Location: Latvia
Device: Cybook, Pocketbook 360
|
Adding cover image to PDF?
Is it possible? It's boring - to scroll rows of similar gray PDF covers. Maybe there is solution?
|
![]() |
![]() |
![]() |
#2 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,546
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Yes, look at this thread.
Though I'm afraid the link given there is not available anymore... Here are the files I use: t2b.pl Code:
#!/usr/bin/perl use GD; my $palette = $0; $palette =~ s/[^\/]+$/palette.ppm/; while ( my $file = shift @ARGV ) { if ( $file =~ /\.pdf$/ ) { open IN, "pdftops -f 1 -l 1 -paper match \"$file\" - | convert -resize 96x144 -map \"$palette\" -dither PNM:- | pnmtopng 2>/dev/null |"; } else { open IN, "convert -resize 96x144 -map \"$palette\" -dither \"$file\" PNM:- | pnmtopng 2>/dev/null |"; } my $in = join( '', <IN> ); close IN; $image = GD::Image->new( $in ); $k = 3; @px = ( ); $left = int( ( 96 - $image->width ) / 2 ); $right = 96 - $image->width - $left; $top = int( ( 144 - $image->height ) / 2 ); $bottom = 144 - $image->height - $top; $file =~ s/\..+?$/_6090.t2b/; open OUT, "> $file"; for ( $i = - $top; $i < 144 - $top; $i ++ ) { for ( $j = - $left; $j < 96 - $left; $j ++ ) { $px[$k --] = ( ( $i >= 0 and $i < $image->height and $j >= 0 and $j < $image->width ) ? $image->getPixel( $j, $i ) : 3 ); if ( $k < 0 ) { # this line can be here because 4 divides 96 print OUT chr( $px[0] + 4 * $px[1] + 16 * $px[2] + 64 * $px[3] ); $k = 3; } } } close OUT; } Code:
P3 2 2 255 0 0 0 85 85 85 170 170 170 255 255 255 |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: May 2008
Location: Latvia
Device: Cybook, Pocketbook 360
|
Thank you!
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding book series to cover??? | artemisblossom | Calibre | 4 | 09-14-2010 05:31 PM |
adding books cover comments | icwright | Calibre | 5 | 12-22-2009 06:48 PM |
Adding a new cover for LRF | pikoman | Calibre | 0 | 11-06-2009 02:43 PM |
Cover Image in PDF Metadata? | ahi | 0 | 05-18-2009 06:56 PM | |
Adding a cover image to mobipocket files | rheostaticsfan | Kindle Formats | 4 | 05-25-2008 03:40 PM |