ImageMagick option commands not found - imagemagick

I'm using ImageMagick to turn my pdf pages into images. It works just fine with default settings but if I try some options, it keeps telling me command not found
For now, I'm doing all this from a SSH client.
The command I'm attempting is:
-quality 90 /usr/bin/convert public_html/so/November-2015.pdf[0] output.jpg
It works just fine without the quality part. I also tried density with no success.

I found out my issue, although I saw this format on other answers the way it works for me is if I put quality -90 after bringing up convert which makes alot of sense now that I think about it.
/usr/bin/convert -quality 90 public_html/so/November-2015.pdf[0] output.jpg

Related

imagemagick splitting large pdf into png's

I have a pdf I'd like to split into individual pictures, each page is a picture, I am using the following imagemajick command to do so:
convert -density 400 mypdf.pdf out.png
and it works fine however I have tested it on the first 5 pages of my pdf and it took 10 seconds, at this rate it should take about half an hour to split my pdf, which seems strange to me considering that I'm not really doing anything fancy, I'm not rotating the images or modifying them in anyway, I'd like to know if there is a faster way to do this. Thanks
Also, I'd like to preserve the quality, I was doing it before without the density flag but the quality dropped dramatically.
PDF rendering is a bit of a mess.
The best system is probably GhostScript, and MuPDF, its library form. It's extremely fast and scales well to large documents. Unfortunately the library licensing (AFL) is difficult and you can't really link directly to the binary.
ImageMagick gets around this restriction by shelling out to the ghostscript command-line tool, but of course that means that rendering a page of a PDF is now a many-stage process: the PDF is copied to /tmp, ghostscript is executed with a set of command-line flags to render the document out to an image file in /tmp, this temporary image file is read back in again, a page is extracted and finally the image is written to the output PNG.
On my laptop I see:
$ time convert -density 400 nipguide.pdf[8] x.png
real 0m2.598s
The other popular PDF renderer is poppler. This came out of the xpdf document previewer project, so it's fast, but is only really happy rendering to RGB. It can struggle on large documents too, and it's GPL, so you can't link to it without also becoming GPL.
libvips links directly to poppler-glib for PDF rendering, so you save some copies. I see:
$ time vips copy nipguide.pdf[page=8,dpi=400] x.png
real 0m0.904s
Finally, there's PDFium. This is the PDF render library from Chrome -- it's the old Foxit PDF previewer, rather crudely cut out and made into a library. It's a little slower than poppler, but it has a very generous license, which means you can use it in situations where poppler would just not work.
There's an experimental libvips branch which uses PDFium for PDF rendering. With that, I see:
$ time vips copy nipguide.pdf[page=8,dpi=400] x.png
real 0m1.152s
If you have Python installed, you should try PyMuPDF. It is a Python binding for MuPDF, extremely easy to use and extremely fast (3 times faster than xpdf).
Rendering PDF pages is bread-and-butter business for this package. Use a script like this:
#----------------------------------------------------------------------------------
import fitz
fname = sys.argv[1] # get filename from command line
doc = fitz.open(fname) # open the file
mat = fitz.Matrix(2,2) # controls resolution: scale factor in x and y direction
for page in doc:
pix = page.getPixmap(matrix=mat, alpha=False)
pix.writePNG("p-%i.png" % page.number) # write the page's image
#----------------------------------------------------------------------------------
More to "Matrix":
This form scales each direction by a factor of 2. So the resulting PNG becomes about 4 times larger than the default version in original, 100% size. Both dimensions can be scaled independently. Rotation or rendering only parts of a page is possible also.
More to PyMuPDF:
Available as binary wheel for Windows, OSX and all Linux versions from PyPI. Installation therefore is a matter of a few seconds. The license for the Python part is GNU GPL 3, for the MuPDF part GNU AFFERO GPL 3. So it's open source and freeware. Creating commercial products is excluded, but you can freely distribute under the same licenses.

imagemagick syntaxerror in pdfopen

I am trying to do PDF to Image conversion. The command I used to do conversion is
convert -density 150 -define registry:temporary-path=/tmp "original_1492599526_Management__CRC.pdf" -quality 50 "imgmagick1492599530_%09d.jpg"
After running above conversion command on red hat linux(rhel 6) machine getting bellow error.
I gone through these links but no help.
http://imagemagick.org/discourse-server/viewtopic.php?t=17790
https://bugzilla.redhat.com/show_bug.cgi?id=1027534
http://forums.justlinux.com/showthread.php?130769-Ghostscript-fails-to-read-PDF-strange-error
Any help appriciated, thanks in advance.
You are using an archaic version of Ghostscript, if I read that error correctly.
Version 8.70 is now 7 years old. I would suggest that you upgrade to the current version and try again.
If the problem persists then you are going to need to post an example file somewhere to look at. A screenshot of an error doesn't tell me much.

In Carrierwave, how to compress images for Google PageSpeed

When I use Google PageSpeed, I'm being told I need to compress my images. Example:
Compressing https://xxx.s3.amazonaws.com/xxxx.jpg could save 33.2KiB (66% reduction).
I'm not sure how to make Google happy here. In Carrierwave, I have the following setting:
version :thumb do
process resize_to_fill: [340, 260]
process :quality => 86
end
If I move the process quality to anything other than 86, the image doesn't look so good. Is there some other setting/trick I'm missing to compress images in a way that will make Google PageSpeed happy and help my site load fast?
I haven't tried resize_to_limit helper, which may help you:
process :resize_to_limit => [340, 260]
It will resize the image to fit within the specified dimensions while
retaining the original aspect ratio. Will only resize the image if it
is larger than the specified dimensions.
There are couple of ways for image optimization that you can perform. Desktop and Online. For Desktop, I would suggest using JPEGOPTIM utility to optimize jpeg files.
Provides lossless optimization (based on optimizing the Huffman
tables) and "lossy" optimization based on setting maximum quality
factor.
If you are on Linux, install it from your terminal:
sudo apt-get install jpegoptim
Then go to the folder where your image is and check first size of it:
du -sh photo.jpg
after that run this command below to optimize it:
jpegoptim photo.jpg
You will see the output.
You can also compress the given image to a specific size to, but it
disables the lossless optimization.
You can also optimize your images in batch with this command:
jpegoptim *.JPG
Another Desktop way is to do basic optimization manually with PS or GIMP. including cropping unnecessary space, reducing color depth to the lowest acceptable level, removing image comments and ( Save for web option )
You can use online solutions too. There are plenty of them, I suggest these ones for example:
https://tinypng.com
https://kraken.io
There is also a WebP format ( developed by Google ) Chrome & Opera support it, but Firefox is not supporting it, so basicly images need to be served conditionally based on the HTTP Accept header sent by browsers capable to display this format. Check this Blog in case that you opt for WebP format, there is a gem which you can use. ( Rails 4 )
I hope it helps,

How to use Imagemagick to remove color profile without removing EXIF data?

Image file in my server are processed using imagemagick. Sometimes I get files with color profiles from users and i use -strip to remove them before uploading the images to storage. Using -strip also removed EXIF data from the images. I'm interested to know if there is a way to only remove color profiles and not exif info regarding geo location and camera settings?
Try this one
convert +profile '!exif,*' in.jpg out.jpg
According to the ImageMagick docu you can use +profile to remove the indicated profile. ImageMagick uses standard filename globbing, so wildcard expressions can be used to exclude specific profiles.
So +profile "!exif,*". will remove all profiles from the image except for the EXIF profile.
Perhaps the +profile flag will work for stripping the colour profiles.
http://www.imagemagick.org/script/command-line-options.php#profile

Create thumbnail from Adobe Illustrator file?

Does anybody know how to create a thumbnail from an Adobe Illustrator file without using Illustrator? I have a php/linux based application and I'd like to do so.
-Dave
By default, Adobe Illustrator saves files as PDF compatible. Unless the file was saved in a strange way, you should be able to use ImageMagick directly to generate a thumbnail. For example:
convert file.ai -thumbnail 250x250 -unsharp 0x.5 thumbnail.png
Note: If the file has multiple artboards (which are interpreted as pages as a PDF), it will generate multiple files or, if saved as a GIF, an animated GIF.
If you can save it in PDF, PS, or EPS format you may be able to manipulate it in things like ImageMagick or Ghostscript.
EDIT:
I think you can actually use ImageMagick's convert with *.ai files as well.

Resources