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?".
omman95
Post
by omman95 » 2010-02-26T09:33:49-07:00
Hello, I use ImageMagick and Gostscript to transform PDF to JPG. It's work perfectly.
I do this :
Code: Select all
convert -verbose -density 300 -interlace none -quality 100 -colorspace YCbCr ".$_FILES['Filedata']['name']."[0] -profile /usr/share/color/icc/PhotoGamutRGB_avg6c.icc -profile /usr/share/color/icc/ECI-RGB.V1.0.icc ".$getfolder[1]."_P4_xl.jpg
I would to crop my PDF file automatically to the trimbox:
My PDF :
I want this :
Can you tell me how I can? I would like to do this :
Code: Select all
-mogrify -usetrimbox mypdf.pdf mypdf_croped.pdf
wisepeace
Post
by wisepeace » 2010-03-19T08:24:06-07:00
Did this work?
omman95
Post
by omman95 » 2010-04-27T00:55:15-07:00
Hello, I don't know if it work. I can't do this script.
Please help ! it's very important for me. I want to crop automoticaly a pdf file in his trimbox.
Thank a lot
omman95
Post
by omman95 » 2010-04-27T02:37:44-07:00
I have an idea.
In PHP, I can know how page I have.
I can open the source of php file and see this line.
Code: Select all
<</BleedBox[85.012 137.535 510.208 704.465]/Contents 2752 0 R/CropBox[0 0 595.22 842]/MediaBox[0 0 595.22 842]/Parent 7421 0 R/Resources 2751 0 R/Rotate 0/TrimBox[99.185 151.709 496.035 690.291]/Type/Page>>
I have as much code as page.
So can you help me to a script in php where, in a "for", I crop page per page with coordinates
Example : I have 6 pages :
for(0, < 6, ++){
imagemagick -crop to X Y H W foo.php[$i] foo_cropped.pdf
}
something like that....
Drarakel
Posts: 547 Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308
Post
by Drarakel » 2010-04-27T03:28:18-07:00
omman95 wrote: Hello, I don't know if it work.
You have to insert "-define pdf:use-trimbox=true" into your ImageMagick command - as Fred (fmw42) told you. Did you try that?
omman95
Post
by omman95 » 2010-04-27T05:28:27-07:00
Thank for you reply :
Code: Select all
mogrify -format pdf -define pdf:use-trimbox=true /TEMP/foo.pdf
this Work !
But, the PDF file content now a picture in the page.
More this image is very bad quality. But It's work!!
Do you want my foo.pdf and my foo_croped.pdf to see the result ?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2010-04-27T09:47:29-07:00
to improve quality, try adding -density. for example twice the quality would be -density 144 or 4x quality would be -density 288
omman95
Post
by omman95 » 2010-04-28T00:59:14-07:00
yes, I add -density but i'm my_pdf.pdf i have some texte, vecto and picture. When I crop him, i'm my_pdf_cropped.pdf, i have just one big picture.
How can i conserve all éléments after the cropping ?
Thank
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2010-04-28T09:08:57-07:00
post a link to an example pdf you need to process so others can see your issue and try to work with it
omman95
Post
by omman95 » 2010-04-29T05:04:21-07:00
Yes Drarakel, I want to conserve the text and the vector. So i don't use imagemagick to do the cropping.
Do you know how can I just crop a PDF file automaticaly on the trimbox? I'm on a ubuntu server.
Thank for your help.
Drarakel
Posts: 547 Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308
Post
by Drarakel » 2010-04-29T13:25:34-07:00
omman95 wrote: Do you know how can I just crop a PDF file
With Adobe Acrobat?
I wouldn't be too optimistic about getting solutions for this - that's an ImageMagick board, you know..
I'm also still a bit unsure what's the purpose behind this. Do you want that other people don't see the 'borders' (of the Mediabox) with Adobe Reader or something like that? And why?
omman95
Post
by omman95 » 2010-05-05T03:09:24-07:00
Hello, my project is a flip book.
I have a PDF HD CMJN with mediabox for printer and from this pdf file, I want to crop it and i do a Low Definition.
After I use PDF2SWF which do a SWF file per page. I insert them in a application where we can turn page like a flip book.
I can do this in Acrobat pro manually but I have a web server with linux Ubuntu and I search a solution.
I use ImageMagick for creating a thumb of the pdf file in jpg.
Drarakel
Posts: 547 Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308
Post
by Drarakel » 2010-05-06T16:13:15-07:00
It would be sufficient if you could copy the TrimBox values to the CropBox (or MediaBox) values. I don't think that there is free software that's able to do this. (But I don't do such stuff, so who knows.. Maybe there is?)
You could possibly change the values of some files directly in PHP. If you change the length of the values though, you could 'break' the PDF. (One could probably repair the broken PDFs with e.g. pdftk.) A very dirty solution.