How do you resize .eps file using ghostscript or some other command line utility available for macOS or ruby? I would like to specify the resolution such as 1000x1000 and not the scale.
Similar to this post but resizing with a specified resolution How to resize an EPS file with free software or command line utility
Thanks #KenS for the help. For reference this is the command I ended up using.
gs -o input.eps -dEPSFitPage -sDEVICE=eps2write -c "<</Install {10 10 scale}>> setpagedevice" -f output.eps
Related
I have url links to image files I want to retrieve from the internet.
I can download the files using curl without issue using:
curl "https://...web address..." > myfileName;
The image files are of various types, some .bmp some .jpg etc. I have been using sip in Terminal on Mac osx to convert each to .png files using:
sips -s format png downloadFileName --out newFileName.png
This works well on files I've saved as downloadedFileName regardless of the starting file type.
As I have many files to process I wanted to pipe the output of the curl download directly into sips, without saving an intermediate file.
I tried the following (which combines my two working steps without the intermediate file name):
curl "https://...web address..." | sips -s format png --out fileName.png
And get a no file error: Error 4: no file was specified.
I've searched the sip man pages but cannot find a reference for piped input and have been unable to find a useful answer searching SO or google.
Is there a way to process an image downloaded using curl directly in sips without first saving the file?
I do not necessarily need the solution to use a pipe, or even be on one line. I have a script that will cycle through a few thousand urls and simply want to avoid saving lots of files that will be deleted a line later.
I should add, I do not necessarily need to use sips either. However, any solution must be able to handle image files of unknown type (which sips does admirably) as no file extension is present on the files.
Thanks
I don't have sips installed but its
manpage indicates that it cannot read
from stdin. However, if you use Bash or ZSH (MacOS default now) you
can use process substitution, in this example I use convert which is
a part of ImageMagick and can convert different image types too:
$ convert <(curl -s https://i.kym-cdn.com/entries/icons/mobile/000/018/012/this_is_fine.jpg) this_is_fine.png
$ file this_is_fine.png
this_is_fine.png: PNG image data, 800 x 450, 8-bit/color RGB, non-interlaced
After doing that this_is_fine.png will be the only file in the
directory with no temporary files
Apparently sips only reads regular files which makes it impossible to use /dev/stdin or named pipes.
However, it is possible using the mature and feature-rich convert command:
$ curl -sL https://picsum.photos/200.jpg | convert - newFilename.png
$ file newFilename.png
newFilename.png: PNG image data, 200 x 200, 8-bit/color RGB, non-interlaced
(First install ImageMagick via brewinstall imagemagick or sudoportinstall ImageMagick.)
ImageMagick permits image data to be read and written from the standard streams STDIN (standard in) and STDOUT (standard out), respectively, using a pseudo-filename of -.
source, section STDIN, STDOUT, and file descriptors
I need to convert a PDF to a cropped TIFF file. For now I have the following command, which crop nothing...
gs -q -dNOPAUSE -r600 -sCompression=lzw -sDEVICE=tiff32nc -sOutputFile=a2.tiff Orange_facture_721368628_20180301.pdf -dDEVICEWIDTHPOINTS=200 -dDEVICEHEIGHTPOINTS=100 -dFIXEDMEDIA -c quit
Any help ?
Thanks
You've put the media size selection (DEVICE....POINTS and FIXEDMEDIA) after the input filename, you need to put them before. Unless you plan on processing multiple files, or have some specialist need to run PostScript after processing the input, the input filename must be the last thing on the command line.
Don't use -c quit, if you want Ghostscript to exit on completion use -dBATCH.
I've been trying to use iconutil to generate .icns icons from the .png images inside the folder "folderthumb.iconset", with the following command:
iconutil -c icns folderthumb.iconset
Everything goes well when the source png have alpha transparency. However, when the PNGs are opaque (from sips, hasAlpha=no) iconutil returns the error:
Unsuported image format
My libpng is v1.6, installed with brew.
Has anyone tips on how to sort this problem out?
Older versions of iconutil did not require the png files to have an alpha channel, the version of iconutil distributed with OS X 10.11 (or did it come with a recent Xcode? I'm not sure...) does.
If you have icons with transparent parts, this should be no problem because I'd expect all graphics tools to include the alpha channel when exporting to png. However if you have a fully opaque icon, most tools and applications remove the alpha channel when exporting to png.
Here is how I resolved this: I installed ImageMagick (e.g. via Mac OS Ports), then used ImageMagick's command line tool convert to add the alpha channel and set the color space to sRGB (which is recommended by iconutil):
convert input.png -alpha Set -colorspace sRGB -define png:format=png32 output.png
If you do this for all icons in your iconset folder, iconutil should then no longer return an error.
how can I convert a .png image to a .icns using applescript? Any help would be greatly appreciated.
Could you just use sips?
sips -s format icns test.png -o test.icns
It doesn't seem to support 1024 x 1024 images or create smaller versions though.
anyone know a free, stable commandline tool (besides ImageMagick) to convert .tif files and .pdf files to either .jpg or .png?
thanks Michelle
I prefer Imagemagick for Windows stuff, but IrfanView performs well, too. It looks like it has switches for command-line conversion of image formats, as well. See the "/convert" option.
tiff2png
On mac os x:
$ brew install tiff2png
$ tiff2png -compression 9 *.tif