composite and backgroud problem
-
- Posts: 14
- Joined: 2011-01-28T06:58:45-07:00
- Authentication code: 8675308
composite and backgroud problem
hi, first sorry for my english, im italian.
i'm trying to create a pdf thumbnail with this features:
-size 100x100 (with a A4 format pdf)
- white background
- a little png icon on the south-right side 32x32
exec("convert \"{$strPDF}[0]\" -colorspace RGB -geometry 96x96 -border 50 -gravity center -crop 100x100+0+0 -background white \"thumb_pdf.jpg\"");
this work, but:
- background is grey!why?
- how can i add the icon onto my image? i read 'composite' docs but i cant..
for better explain:
- this is what i have now
- what im looking for
- best solution 100x100 img with a inner border on document
i'm trying to create a pdf thumbnail with this features:
-size 100x100 (with a A4 format pdf)
- white background
- a little png icon on the south-right side 32x32
exec("convert \"{$strPDF}[0]\" -colorspace RGB -geometry 96x96 -border 50 -gravity center -crop 100x100+0+0 -background white \"thumb_pdf.jpg\"");
this work, but:
- background is grey!why?
- how can i add the icon onto my image? i read 'composite' docs but i cant..
for better explain:
- this is what i have now
- what im looking for
- best solution 100x100 img with a inner border on document
Re: composite and backgroud problem
Good try but as you say not the result you wanted; try this:
Some error reporting added that you can comment out or remove.
This was interesting as I did not know you needed to do this as I normaly input the pdf name not the variable in my tests \"{$strPDF}[0]\"
You probably want to post in the user section next time as this is not using Magick wand and you willl probably get more replys.
To make longer lines more user freindly I write my code this way now:
Code: Select all
<?php
$strPDF = "booklet.pdf";
$array=array();
echo "<pre>";
exec("convert -density 300 \"{$strPDF}[0]\" -thumbnail 100x100 -background white -gravity center -extent 100x100 logo.png -gravity southeast -composite thumb_pdf.jpg 2>&1", $array);
echo "<br>".print_r($array)."<br>";
?>
This was interesting as I did not know you needed to do this as I normaly input the pdf name not the variable in my tests \"{$strPDF}[0]\"
You probably want to post in the user section next time as this is not using Magick wand and you willl probably get more replys.
To make longer lines more user freindly I write my code this way now:
Code: Select all
$cmd = "-density 300 \"{$strPDF}[0]\" -thumbnail 100x100 -background white ".
" -gravity center -extent 100x100 logo.png -gravity southeast -composite";
exec("convert $cmd thumb_pdf.jpg);
-
- Posts: 14
- Joined: 2011-01-28T06:58:45-07:00
- Authentication code: 8675308
Re: composite and backgroud problem
thanks for show me how i can see error reporting
i tried yours..wtf? i want to create logo.png! why the script try to open image? (directory permission alright)
Code: Select all
Array
(
[0] => convert: unable to open image `logo.png': No such file or directory.
[1] => convert: unable to open file `logo.png'.
)
Re: composite and backgroud problem
Change logo.png to the name of the icon you want to put on top of the pdf. You did not say what it was called in your post.
Imagemagick error reporting is not always helpful!
Imagemagick error reporting is not always helpful!
-
- Posts: 14
- Joined: 2011-01-28T06:58:45-07:00
- Authentication code: 8675308
Re: composite and backgroud problem
yep i inverted the filesBonzo wrote:Change logo.png to the name of the icon you want to put on top of the pdf. You did not say what it was called in your post.
now results:
thumb on the left and black backgound..why??
ps: can i control jpg compression rate?quality is awful..
Re: composite and backgroud problem
What code are you using ?
You can add -quality 100 just before the image save name and increase the -density from 300 to 400 to improve quality
You can add -quality 100 just before the image save name and increase the -density from 300 to 400 to improve quality
-
- Posts: 14
- Joined: 2011-01-28T06:58:45-07:00
- Authentication code: 8675308
Re: composite and backgroud problem
yoursBonzo wrote:What code are you using ?
You can add -quality 100 just before the image save name and increase the -density from 300 to 400 to improve quality
Code: Select all
exec("convert -density 300 \"{$strPDF}[0]\" -thumbnail 100x100 -background white -gravity center -extent 100x100 pdf_icon.png -gravity southeast -composite pdfthumb.png 2>&1", $array);
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite and backgroud problem
the use of -border requires setting -bordercolor and not -background and usually before -border. Put the settings before the operation.
Re: composite and backgroud problem
Thats strange as it worked OK for me; have you tried another pdf as there may be a problem with that one ?
Improve the quality ( -quality has no effect on .png images ? ):
Improve the quality ( -quality has no effect on .png images ? ):
Code: Select all
exec("convert -density 400 \"{$strPDF}[0]\" -thumbnail 100x100 -background white -gravity center -extent 100x100 pdf_icon.png -gravity southeast -composite pdfthumb.png 2>&1", $array);
-
- Posts: 14
- Joined: 2011-01-28T06:58:45-07:00
- Authentication code: 8675308
Re: composite and backgroud problem
i have ImageMagick 6.2.8..maybe create problem?
for some pdf i see some warnings, but the output files is the same (thumb on the left and black back):
for some pdf i see some warnings, but the output files is the same (thumb on the left and black back):
Code: Select all
Array
(
[0] => **** Warning: Fonts with Subtype = /TrueType should be embedded.
[1] => But Times New Roman is not embedded.
[2] => **** Warning: Fonts with Subtype = /TrueType should be embedded.
[3] => But Arial,BoldItalic is not embedded.
[4] => **** Warning: Fonts with Subtype = /TrueType should be embedded.
[5] => But Arial is not embedded.
[6] => **** Warning: Fonts with Subtype = /TrueType should be embedded.
[7] => But Arial,Bold is not embedded.
[8] =>
[9] => **** This file had errors that were repaired or ignored.
[10] => **** The file was produced by:
[11] => **** >>>> Microsoft® Office Word 2007 <<<<
[12] => **** Please notify the author of the software that produced this
[13] => **** file that it does not conform to Adobe's published PDF
[14] => **** specification.
[15] =>
)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite and backgroud problem
IM 6.2.8 is very ancient (about 400 versions old) a lot of things were not implemented at that time. You would be best to upgrade if possible.
For example from Anthony's pages:
Before IM version v6.3.2, "-extent" just cleared the memory of any new areas to zero, or straight black. It did not fill the areas with "-background" color.
see http://www.imagemagick.org/Usage/crop/#extent
For example from Anthony's pages:
Before IM version v6.3.2, "-extent" just cleared the memory of any new areas to zero, or straight black. It did not fill the areas with "-background" color.
see http://www.imagemagick.org/Usage/crop/#extent
-
- Posts: 14
- Joined: 2011-01-28T06:58:45-07:00
- Authentication code: 8675308
Re: composite and backgroud problem
im on a shared hosting, dont think they'll updrage the software for me, but i'll ask for.
there isnt a different way for make this for my version?
there isnt a different way for make this for my version?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite and backgroud problem
I really don't understand why you have included -geometry 96x96 as it does nothing here. Also why -border 50 unless the resulting pdf is too small (and if you really need it then you need to add -bordercolor white).exec("convert \"{$strPDF}[0]\" -colorspace RGB -geometry 96x96 -border 50 -gravity center -crop 100x100+0+0 -background white \"thumb_pdf.jpg\"");
The size of the pdf is controlled by -density and not -geometry or -size or -resize. So add the appropriate -density value to make it bigger or smaller.
But try this:
exec("convert -colorspace RGB \"{$strPDF}[0]\" -gravity center -background white -crop 100x100+0+0 +repage \"thumb_pdf.jpg\"");
or for higher quality (supersampling)
exec("convert -colorspace RGB -density 288 \"{$strPDF}[0]\" -resize 25% -gravity center -background white -crop 100x100+0+0 +repage \"thumb_pdf.jpg\"");
If these are too small, then increase the density (above 72)
exec("convert -colorspace RGB -density 150 \"{$strPDF}[0]\" -gravity center -background white -crop 100x100+0+0 +repage \"thumb_pdf.jpg\"");
or if you want to add a white border, use
exec("convert -colorspace RGB \"{$strPDF}[0]\" -gravity center -bordercolor white -border 50 -background white -crop 100x100+0+0 +repage \"thumb_pdf.jpg\"");
etc with the higher quality one
Let us know what you get so we can then try to fine tune it for your needs. Explain if not correct, what is wrong and link to the results.
Re: composite and backgroud problem
Try this:
I have also added some sharpening to the pdf but I would say at this size you are not going to get a good quality anyway.
Code: Select all
exec("convert -size 100x100 xc:white \( -density 300 \"{$strPDF}[0]\" -thumbnail 100x100 -unsharp 1.5x1+0.7+0.02 \) -gravity center -composite image-cropped-2.png -gravity southeast -composite thumb_pdf1.jpg 2>&1", $array);
-
- Posts: 14
- Joined: 2011-01-28T06:58:45-07:00
- Authentication code: 8675308
Re: composite and backgroud problem
this works..im very very very gratefulBonzo wrote:Try this:I have also added some sharpening to the pdf but I would say at this size you are not going to get a good quality anyway.Code: Select all
exec("convert -size 100x100 xc:white \( -density 300 \"{$strPDF}[0]\" -thumbnail 100x100 -unsharp 1.5x1+0.7+0.02 \) -gravity center -composite image-cropped-2.png -gravity southeast -composite thumb_pdf1.jpg 2>&1", $array);
ps: whats sharpening?