ImageMagick: Zoom SVG and convert it to PNG? - svg

I have the following 8×8 SVG graphic for which I want a scaled version of as PNG. (I found no way to upload SVG so you can see it.) The SVG consist of 8×8 black/white "pixels".
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
<path fill="#fff" d="M0,0H8V8H0"/>
<path fill="#000" d="M0,0H7V1H6V0H5V3H8V2H7V5H6V5H6V4H8V6H7V8H8V7H1V8H2V5H3V6H4V7H5V4H2V1H3V2H4V3H1V4H0"
fill-rule="evenodd"/>
</svg>
When I am using ImageMagick's
> convert a3x2.svg -scale 80x80 a3x2.png
as of this answer for scaling a PNG, then I am getting the following result which has nothing to do with the input:
What I want is a scaled black/white PNG where each pixel has a "size" of 10×10; no smoothing or dithering. What does not work is -resize 80x80 (will blur and still has wrong pixel values).
Edit
According to this answer, a solution with Inkscape is
> inkscape -w 80 -h 80 a3x2.svg -o a3x2.png
which works, but I'd rather use ImageMagick. For reference, here is the result with Inkscape so you can see that the result of convert from above is not as expected.
> convert -version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib
Edit 2
As asked in a comment, here is the result of
> convert -verbose a3x2.svg txt:
'inkscape' '/tmp/magick-445746DLWe3-eb4nrF' --export-filename='/tmp/magick-445746FrMsKiicip2C' --export-dpi='96,96' --export-background='rgb(100%,100%,100%)' --export-background-opacity='1' > '/tmp/magick-445746cd-3Bn1wlmb8' 2>&1
mvg:/tmp/magick-445746UpfR0goE2RRA=>/tmp/magick-445746UpfR0goE2RRA MVG 8x8 8x8+0+0 16-bit sRGB 445B 0.000u 0:00.000
a3x2.svg MVG 8x8 8x8+0+0 16-bit sRGB 445B 0.000u 0:00.000
# ImageMagick pixel enumeration: 8,8,65535,srgba
0,0: (0,0,0,65535) #000000000000FFFF black
1,0: (0,0,0,65535) #000000000000FFFF black
2,0: (0,0,0,65535) #000000000000FFFF black
3,0: (0,0,0,65535) #000000000000FFFF black
4,0: (0,0,0,65535) #000000000000FFFF black
5,0: (0,0,0,65535) #000000000000FFFF black
6,0: (0,0,0,65535) #000000000000FFFF black
7,0: (0,0,0,65535) #000000000000FFFF black
0,1: (0,0,0,65535) #000000000000FFFF black
1,1: (0,0,0,65535) #000000000000FFFF black
2,1: (0,0,0,65535) #000000000000FFFF black
3,1: (0,0,0,65535) #000000000000FFFF black
4,1: (0,0,0,65535) #000000000000FFFF black
5,1: (0,0,0,65535) #000000000000FFFF black
6,1: (0,0,0,65535) #000000000000FFFF black
7,1: (0,0,0,65535) #000000000000FFFF black
0,2: (0,0,0,65535) #000000000000FFFF black
1,2: (0,0,0,65535) #000000000000FFFF black
2,2: (0,0,0,65535) #000000000000FFFF black
3,2: (0,0,0,65535) #000000000000FFFF black
4,2: (0,0,0,65535) #000000000000FFFF black
5,2: (0,0,0,65535) #000000000000FFFF black
6,2: (61439,61439,61439,65535) #EFFFEFFFEFFFFFFF srgba(94%,94%,94%,1)
7,2: (0,0,0,65535) #000000000000FFFF black
0,3: (0,0,0,65535) #000000000000FFFF black
1,3: (0,0,0,65535) #000000000000FFFF black
2,3: (0,0,0,65535) #000000000000FFFF black
3,3: (0,0,0,65535) #000000000000FFFF black
4,3: (0,0,0,65535) #000000000000FFFF black
5,3: (0,0,0,65535) #000000000000FFFF black
6,3: (0,0,0,65535) #000000000000FFFF black
7,3: (0,0,0,65535) #000000000000FFFF black
0,4: (0,0,0,65535) #000000000000FFFF black
1,4: (0,0,0,65535) #000000000000FFFF black
2,4: (0,0,0,65535) #000000000000FFFF black
3,4: (0,0,0,65535) #000000000000FFFF black
4,4: (0,0,0,65535) #000000000000FFFF black
5,4: (0,0,0,65535) #000000000000FFFF black
6,4: (0,0,0,65535) #000000000000FFFF black
7,4: (0,0,0,65535) #000000000000FFFF black
0,5: (65535,65535,65535,65535) #FFFFFFFFFFFFFFFF white
1,5: (61439,61439,61439,65535) #EFFFEFFFEFFFFFFF srgba(94%,94%,94%,1)
2,5: (0,0,0,65535) #000000000000FFFF blaca3x2.svg=> MVG 8x8 8x8+0+0 16-bit sRGB 445B 0.000u 0:00.000
k
3,5: (0,0,0,65535) #000000000000FFFF black
4,5: (61439,61439,61439,65535) #EFFFEFFFEFFFFFFF srgba(94%,94%,94%,1)
5,5: (0,0,0,65535) #000000000000FFFF black
6,5: (0,0,0,65535) #000000000000FFFF black
7,5: (0,0,0,65535) #000000000000FFFF black
0,6: (65535,65535,65535,65535) #FFFFFFFFFFFFFFFF white
1,6: (65535,65535,65535,65535) #FFFFFFFFFFFFFFFF white
2,6: (0,0,0,65535) #000000000000FFFF black
3,6: (0,0,0,65535) #000000000000FFFF black
4,6: (0,0,0,65535) #000000000000FFFF black
5,6: (0,0,0,65535) #000000000000FFFF black
6,6: (0,0,0,65535) #000000000000FFFF black
7,6: (0,0,0,65535) #000000000000FFFF black
0,7: (65535,65535,65535,65535) #FFFFFFFFFFFFFFFF white
1,7: (0,0,0,65535) #000000000000FFFF black
2,7: (0,0,0,65535) #000000000000FFFF black
3,7: (0,0,0,65535) #000000000000FFFF black
4,7: (0,0,0,65535) #000000000000FFFF black
5,7: (0,0,0,65535) #000000000000FFFF black
6,7: (0,0,0,65535) #000000000000FFFF black
7,7: (0,0,0,65535) #000000000000FFFF black

Mmmm... I don't know what's going on, but I can confirm that if I use the rsvg delegate in place of the MVG delegate, I get the correct result:
I find it simplest to use the docker alpine image to demonstrate because it is very current and has an extensive set of delegates without any user configuration. So, I just did:
# Start latest alpine image, bind mounting current working directory to /work
docker run -it -v "$(pwd)":/work alpine
apk update && apk add imagemagick
identify -version
Version: ImageMagick 7.1.0-52 Q16-HDRI aarch64 20549 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jng jpeg jxl lcms ltdl lzma png ps rsvg tiff webp x xml zlib
Compiler: gcc (12.2)
magick image.svg -scale 80x80 result.png

What worked for me on x86_64-linux-gnu is to update from v6.9 to v7.1 and then use
> convert a3x2.svg -scale 80x80 a3x2.png
as expected. More specifically, I downloaded ImageMagick-7.1.0-60.tar.gz from https://imagemagick.org/archive/ (there is also ImageMagick.tar.gz which presumably is the newest version, but I am not sure about that so that I downloaded 7.1 explicitly).
Extract the sources:tar xfz ImageMagick-7.1.0-60.tar.gz
Suppose the sources are at /home/me/sources/ImageMagick-7.1.0-60. Create a build directory at /home/me/build/imagemagick-7.1.
cd to the build directory and configure:cd /home/me/build/imagemagick-7.1/home/me/sources/ImageMagick-7.1.0-60/configure --prefix=/home/me/install/imagemagick-7.1
Run make and then make install.
Add the /home/me/install/imagemagick-7.1/bin directory to PATH, alternative use alias or links to point to the tools located there.
To my great surprise, I didn't get any dependency problems, and everything appears to work fine for now. FYI, using the RPM packages did not work for me due to missing dependencies (≈50 of them).

Related

Cannot open .jpg, .png, or .tif files with ImageMagick, only .gif files work

I am using Ubuntu 18.04.1 LTS (Bionic Beaver) on Windows Subsystem for Linux. I installed ImageMagick according to these instructions, the only exception being ImageMagick version is currently 7.0.10-34, not 7.0.4-5: https://www.tutorialspoint.com/how-to-install-imagemagick-on-ubuntu.
I've downloaded a test .gif and successfully run commands like convert giphy.gif -flip new.gif and magick giphy.gif giphy.tif and identify giphy.gif, but when I try to run the same commands with "panda.jpg" or "15k4881.tif", I get the following errors:
$ identify panda.jpg
identify: no decode delegate for this image format `JPG' # error/constitute.c/ReadImage/562.
$ convert 15k4881.tif -flip 15k4881.tif
convert: no decode delegate for this image format `TIF' # error/constitute.c/ReadImage/562. convert: no images defined `15k4881.tif' # error/convert.c/ConvertImageCommand/3285.
I'm very, very new to all this but I can tell from the following outputs that .jpg, .tif, and .png are not supported nor have the proper delegates. What do I do to be able to modify these file types?
$ identify -list format gives me
Format Mode Description
3FR r-- Hasselblad CFV/H3D39II
3G2 r-- Media Container
3GP r-- Media Container
A* rw+ Raw alpha samples
AAI* rw+ AAI Dune image
AI rw- Adobe Illustrator CS2
APNG rw+ Animated Portable Network Graphics
ART* rw- PFS: 1st Publisher Clip Art
ARW r-- Sony Alpha Raw Image Format
ASHLAR* -w+ Image sequence laid out in continuous irregular courses
AVI r-- Microsoft Audio/Visual Interleaved
AVS* rw+ AVS X image
B* rw+ Raw blue samples
BGR* rw+ Raw blue, green, and red samples
BGRA* rw+ Raw blue, green, red, and alpha samples
BGRO* rw+ Raw blue, green, red, and opacity samples
BMP* rw- Microsoft Windows bitmap image
BMP2* rw- Microsoft Windows bitmap image (V2)
BMP3* rw- Microsoft Windows bitmap image (V3)
BRF* -w- BRF ASCII Braille format
C* rw+ Raw cyan samples
CAL* r-- Continuous Acquisition and Life-cycle Support Type 1
Specified in MIL-R-28002 and MIL-PRF-28002
CALS* r-- Continuous Acquisition and Life-cycle Support Type 1
Specified in MIL-R-28002 and MIL-PRF-28002
CANVAS* r-- Constant image uniform color
CAPTION* r-- Caption
CIN* rw- Cineon Image File
CIP* -w- Cisco IP phone image format
CLIP* rw+ Image Clip Mask
CMYK* rw+ Raw cyan, magenta, yellow, and black samples
CMYKA* rw+ Raw cyan, magenta, yellow, black, and alpha samples
CR2 r-- Canon Digital Camera Raw Image Format
CR3 r-- Canon Digital Camera Raw Image Format
CRW r-- Canon Digital Camera Raw Image Format
CUBE* r-- Cube LUT
CUR* rw- Microsoft icon
CUT* r-- DR Halo
DATA* rw+ Base64-encoded inline images
DCM* r-- Digital Imaging and Communications in Medicine image
DICOM is used by the medical community for images like X-rays. The
specification, "Digital Imaging and Communications in Medicine
(DICOM)", is available at http://medical.nema.org/. In particular,
see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
and supplement 61 which adds JPEG-2000 encoding.
DCR r-- Kodak Digital Camera Raw Image File
DCRAW r-- Raw Photo Decoder (dcraw)
DCX* rw+ ZSoft IBM PC multi-page Paintbrush
DDS* rw+ Microsoft DirectDraw Surface
DNG r-- Digital Negative
DPX* rw- SMPTE 268M-2003 (DPX 2.0)
Digital Moving Picture Exchange Bitmap, Version 2.0.
See SMPTE 268M-2003 specification at http://www.smtpe.org
DXT1* rw+ Microsoft DirectDraw Surface
DXT5* rw+ Microsoft DirectDraw Surface
EPDF rw- Encapsulated Portable Document Format
EPI rw- Encapsulated PostScript Interchange format
EPS rw- Encapsulated PostScript
EPS2 -w- Level II Encapsulated PostScript
EPS3 -w+ Level III Encapsulated PostScript
EPSF rw- Encapsulated PostScript
EPSI rw- Encapsulated PostScript Interchange format
ERF r-- Epson RAW Format
FAX* rw+ Group 3 FAX
FAX machines use non-square pixels which are 1.5 times wider than
they are tall but computer displays use square pixels, therefore
FAX images may appear to be narrow unless they are explicitly
resized using a geometry of "150x100%".
FILE* r-- Uniform Resource Locator (file://)
FITS* rw- Flexible Image Transport System
FLV rw+ Flash Video Stream
FRACTAL* r-- Plasma fractal image
FTP* --- Uniform Resource Locator (ftp://)
FTS* rw- Flexible Image Transport System
G* rw+ Raw green samples
G3* rw- Group 3 FAX
G4* rw- Group 4 FAX
GIF* rw+ CompuServe graphics interchange format
GIF87* rw- CompuServe graphics interchange format (version 87a)
GRADIENT* r-- Gradual linear passing from one shade to another
GRAY* rw+ Raw gray samples
GRAYA* rw+ Raw gray and alpha samples
HALD* r-- Identity Hald color lookup table image
HDR* rw+ Radiance RGBE image format
HISTOGRAM* -w- Histogram of the image
HRZ* rw- Slow Scan TeleVision
HTM* -w- Hypertext Markup Language and a client-side image map
HTML* -w- Hypertext Markup Language and a client-side image map
HTTP* --- Uniform Resource Locator (http://)
HTTPS* r-- Uniform Resource Locator (https://)
ICB* rw- Truevision Targa image
ICO* rw+ Microsoft icon
ICON* rw- Microsoft icon
IIQ r-- Phase One Raw Image Format
INFO -w+ The image format and characteristics
INLINE* rw+ Base64-encoded inline images
IPL* rw+ IPL Image Sequence
ISOBRL* -w- ISO/TR 11548-1 format
ISOBRL6* -w- ISO/TR 11548-1 format 6dot
JNX* r-- Garmin tile format
JSON -w+ The image format and characteristics
K* rw+ Raw black samples
K25 r-- Kodak Digital Camera Raw Image Format
KDC r-- Kodak Digital Camera Raw Image Format
LABEL* r-- Image label
M* rw+ Raw magenta samples
M2V rw+ MPEG Video Stream
M4V rw+ Raw VIDEO-4 Video
MAC* r-- MAC Paint
MAP* rw- Colormap intensities and indices
MASK* rw+ Image Clip Mask
MAT rw+ MATLAB level 5 image format
MATTE* -w+ MATTE format
MEF r-- Mamiya Raw Image File
MIFF* rw+ Magick Image File Format
MKV rw+ Multimedia Container
MONO* rw- Raw bi-level bitmap
MOV rw+ MPEG Video Stream
MP4 rw+ VIDEO-4 Video Stream
MPC* rw+ Magick Persistent Cache image format
MPEG rw+ MPEG Video Stream
MPG rw+ MPEG Video Stream
MRW r-- Sony (Minolta) Raw Image File
MSL* --- Magick Scripting Language
MSVG -w+ ImageMagick's own SVG internal renderer
MTV* rw+ MTV Raytracing image format
MVG* rw- Magick Vector Graphics
NEF r-- Nikon Digital SLR Camera Raw Image File
NRW r-- Nikon Digital SLR Camera Raw Image File
NULL* rw- Constant image of uniform color
O* rw+ Raw opacity samples
ORA --- OpenRaster format
ORF r-- Olympus Digital Camera Raw Image File
OTB* rw- On-the-air bitmap
PAL* rw- 16bit/pixel interleaved YUV
PALM* rw+ Palm pixmap
PAM* rw+ Common 2-dimensional bitmap format
PANGO* --- Pango Markup Language
PATTERN* r-- Predefined pattern
PBM* rw+ Portable bitmap format (black and white)
PCD* rw- Photo CD
PCDS* rw- Photo CD
PCL rw+ Printer Control Language
PCT* rw- Apple Macintosh QuickDraw/PICT
PCX* rw- ZSoft IBM PC Paintbrush
PDB* rw+ Palm Database ImageViewer Format
PDF rw+ Portable Document Format
PDFA rw+ Portable Document Archive Format
PEF r-- Pentax Electronic File
PES* r-- Embrid Embroidery Format
PFM* rw+ Portable float format
PGM* rw+ Portable graymap format (gray scale)
PGX* rw- JPEG 2000 uncompressed format
PICON* rw- Personal Icon
PICT* rw- Apple Macintosh QuickDraw/PICT
PIX* r-- Alias/Wavefront RLE image format
PLASMA* r-- Plasma fractal image
PNM* rw+ Portable anymap
POCKETMOD rw+ Pocketmod Personal Organizer
PPM* rw+ Portable pixmap format (color)
PS rw+ PostScript
PS2 -w+ Level II PostScript
PS3 -w+ Level III PostScript
PSB* rw+ Adobe Large Document Format
PSD* rw+ Adobe Photoshop bitmap
PWP* r-- Seattle Film Works
R* rw+ Raw red samples
RADIAL-GRADIENT* r-- Gradual radial passing from one shade to another
RAF r-- Fuji CCD-RAW Graphic File
RAS* rw+ SUN Rasterfile
RAW r-- Raw
RGB* rw+ Raw red, green, and blue samples
RGB565* r-- Raw red, green, blue samples in 565 format
RGBA* rw+ Raw red, green, blue, and alpha samples
RGBO* rw+ Raw red, green, blue, and opacity samples
RGF* rw- LEGO Mindstorms EV3 Robot Graphic Format (black and white)
RLA* r-- Alias/Wavefront image
RLE* r-- Utah Run length encoded image
RMF r-- Raw Media Format
RW2 r-- Panasonic Lumix Raw Image
SCR* r-- ZX-Spectrum SCREEN$
SCREENSHOT* r-- Screen shot
SCT* r-- Scitex HandShake
SFW* r-- Seattle Film Works
SGI* rw+ Irix RGB image
SHTML* -w- Hypertext Markup Language and a client-side image map
SIX* rw- DEC SIXEL Graphics Format
SIXEL* rw- DEC SIXEL Graphics Format
SPARSE-COLOR* -w+ Sparse Color
SR2 r-- Sony Raw Format 2
SRF r-- Sony Raw Format
STEGANO* r-- Steganographic image
SUN* rw+ SUN Rasterfile
SVG rw+ Scalable Vector Graphics
SVGZ -w+ Compressed Scalable Vector Graphics
TEXT* r-- Text
TGA* rw- Truevision Targa image
THUMBNAIL* -w+ EXIF Profile Thumbnail
TILE* r-- Tile image with a texture
TIM* r-- PSX TIM
TM2* r-- PS2 TIM2
TXT* rw+ Text
UBRL* -w- Unicode Text format
UBRL6* -w- Unicode Text format 6dot
UIL* -w- X-Motif UIL table
UYVY* rw- 16bit/pixel interleaved YUV
VDA* rw- Truevision Targa image
VICAR* rw- VICAR rasterfile format
VID* rw+ Visual Image Directory
VIFF* rw+ Khoros Visualization image
VIPS* rw+ VIPS image
VST* rw- Truevision Targa image
WBMP* rw- Wireless Bitmap (level 0) image
WEBM rw+ Open Web Media
WMV rw+ Windows Media Video
WPG* r-- Word Perfect Graphics
X3F r-- Sigma Camera RAW Picture File
XBM* rw- X Windows system bitmap (black and white)
XC* r-- Constant image uniform color
XCF* r-- GIMP image
XPM* rw- X Windows system pixmap (color)
XPS r-- Microsoft XML Paper Specification
XV* rw+ Khoros Visualization image
Y* rw+ Raw yellow samples
YCbCr* rw+ Raw Y, Cb, and Cr samples
YCbCrA* rw+ Raw Y, Cb, Cr, and alpha samples
YUV* rw- CCIR 601 4:1:1 or 4:2:2
* native blob support
r read support
w write support
+ support for multiple images
$ convert -list configure gives me
Path: /usr/local/lib/ImageMagick-7.0.10//config-Q16HDRI/configure.xml
Name Value
-------------------------------------------------------------------------------
CC gcc
CFLAGS -fopenmp -Wall -g -O2 -mtune=core2 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
CODER_PATH /usr/local/lib/ImageMagick-7.0.10/modules-Q16HDRI/coders
CONFIGURE ./configure
CONFIGURE_PATH /usr/local/etc/ImageMagick-7/
COPYRIGHT Copyright (C) 1999-2020 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick-7
CXX g++
CXXFLAGS -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES mpeg
DISTCHECK_CONFIG_FLAGS --disable-deprecated --with-quantum-depth=16 --with-jemalloc=no --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-rsvg=no --with-wmf=no --with-perl=no
DOCUMENTATION_PATH /usr/local/share/doc/ImageMagick-7
EXEC-PREFIX /usr/local
EXECUTABLE_PATH /usr/local/bin
FEATURES DPC HDRI Cipher OpenMP
FILTER_PATH /usr/local/lib/ImageMagick-7.0.10/modules-Q16HDRI/filters
GIT_REVISION 17696
HOST x86_64-pc-linux-gnu
INCLUDE_PATH /usr/local/include/ImageMagick-7
LDFLAGS -L/usr/local/lib
LIB_VERSION 0x70A
LIB_VERSION_NUMBER 7,0,10,34
LIBRARY_PATH /usr/local/lib/ImageMagick-7.0.10
LIBS -lm -lpthread -lgomp
NAME ImageMagick
PCFLAGS -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
PREFIX /usr/local
QuantumDepth 16
RELEASE_DATE 2020-10-22
SHARE_PATH /usr/local/share/ImageMagick-7
SHAREARCH_PATH /usr/local/lib/ImageMagick-7.0.10/config-Q16HDRI
TARGET_CPU x86_64
TARGET_OS linux-gnu
TARGET_VENDOR pc
VERSION 7.0.10
WEBSITE https://imagemagick.org
Path: [built-in]
Name Value
-------------------------------------------------------------------------------
DELEGATES
FEATURES Cipher DPC HDRI OpenMP(4.5)
MAGICK_TEMPORARY_PATH /tmp
NAME ImageMagick
QuantumDepth Q16
and convert -list delegate gives me
Path: /usr/local/etc/ImageMagick-7/delegates.xml
Delegate Command
-------------------------------------------------------------------------------
blender => "blender' -b '%i' -F PNG -o '%o''\n'magick' convert -concatenate '%o*.png' '%o"
bmp<= jxr "/bin/mv '%i' '%i.bmp'; 'JxrEncApp' -i '%i.bmp' -o '%o.jxr'; /bin/mv '%i.bmp' '%i'; /bin/mv '%o.jxr' '%o"
bmp<= wdp "/bin/mv '%i' '%i.bmp'; 'JxrEncApp' -i '%i.bmp' -o '%o.jxr'; /bin/mv '%i.bmp' '%i'; /bin/mv '%o.jxr' '%o"
bpg => "bpgdec' -b 16 -o '%o.png' '%i'; /bin/mv '%o.png' '%o"
cdr => "#UniconvertorDelegate#' '%i' '%o.svg'; /bin/mv '%o.svg' '%o"
cgm => "#UniconvertorDelegate#' '%i' '%o.svg'; /bin/mv '%o.svg' '%o"
dng:decode => "ufraw-batch' --silent --create-id=also --out-type=png --out-depth=16 '--output=%u.png' '%i"
doc => "libreoffice' --headless --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
docx => "libreoffice' --headless --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
dot => "dot' -Tsvg '%i' -o '%o"
dvi => "dvips' -sstdout=%%stderr -o '%o' '%i"
dxf => "#UniconvertorDelegate#' '%i' '%o.svg'; /bin/mv '%o.svg' '%o"
eps<=>pdf "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 '-sDEVICE=pdfwrite' '-sOutputFile=%o' '-f%i"
eps<=>ps "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=ps2write' '-sOutputFile=%o' '-f%i"
fig => "#UniconvertorDelegate#' '%i' '%o.svg'; /bin/mv '%o.svg' '%o"
hpg => "hp2xx' -sstdout=%%stderr -m eps -f `basename '%o'` '%i'; /bin/mv -f `basename '%o'` '%o"
hpgl => "hp2xx' -sstdout=%%stderr -m eps -f `basename '%o'` '%i'; /bin/mv -f `basename '%o'` '%o"
htm => "html2ps' -U -o '%o' '%i"
html => "html2ps' -U -o '%o' '%i"
https:decode => "curl' -s -k -L -o '%u.dat' 'https:%M"
ilbm => "ilbmtoppm' '%i' > '%o"
jpg<= lep "lepton' '%i' '%o"
jxr => "/bin/mv '%i' '%i.jxr'; 'JxrDecApp' -i '%i.jxr' -o '%o.pnm'; /bin/mv '%i.jxr' '%i'; /bin/mv '%o.pnm' '%o"
lep => "lepton' '%i' '%o"
miff<= show "magick' display -immutable -delay 0 -title '%M' '%i"
odt => "libreoffice' --headless --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
pdf<=>eps "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sPDFPassword='%a' '-sDEVICE=eps2write' '-sOutputFile=%o' '-f%i"
pdf<=>ps "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=ps2write' -sPDFPassword='%a' '-sOutputFile=%o' '-f%i"
png<= bpg "bpgenc' -b 12 -q '%~' -o '%o' '%i"
png<= webp "cwebp' -quiet %Q '%i' -o '%o"
pnm<= trace "potrace' --svg --output '%o' '%i"
pnm<= ilbm "ppmtoilbm' -24if '%i' > '%o"
ppt => "libreoffice' --headless --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
pptx => "libreoffice' --headless --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
ps<= prt " lpr' '%i"
ps<=>eps "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=eps2write' '-sOutputFile=%o' '-f%i"
ps<=>pdf "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pdfwrite' '-sOutputFile=%o' '-f%i"
ps<= print "#LPRDelegateDefault# '%i"
shtml => "html2ps' -U -o '%o' '%i"
sid => "mrsidgeodecode' -if sid -i '%i' -of tif -o '%o' > '%u"
svg => "rsvg-convert' -o '%o' '%i"
tiff<= launch "gimp' '%i"
video:decode => "avconv' -nostdin -v -1 -i '%i' -vframes %S -vcodec pam -an -f rawvideo -y '%u.pam' 2> '%u"
wdp => "/bin/mv '%i' '%i.jxr'; 'JxrDecApp' -i '%i.jxr' -o '%o.bmp'; /bin/mv '%i.jxr' '%i'; /bin/mv '%o.bmp' '%o"
webp => "dwebp' -pam '%i' -o '%o"
xls => "libreoffice' --headless --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
xlsx => "libreoffice' --headless --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
If you install ImageMagick from source, ensure you have the needed delegates.
Do something like the following: e.g. these steps are required in order to Install ImageMagick with JPG, PNG and TIFF delegates for example.
Update apt index:
sudo apt-get update
Install Build-Essential in order to configure and make the final Install:
sudo apt-get install build-essential
libjpg62-dev required in order to work with basic JPG files:
sudo apt-get install -y libjpeg62-dev
libtiff-dev is required in order to work with TIFF file format:
sudo apt-get install -y libtiff-dev
libpng-dev required in order to work with basic PNG files:
sudo apt-get install -y libpng-dev
Download ImageMagick:
wget https://www.imagemagick.org/download/ImageMagick.tar.gz
Untar Imagemagick:
tar xvzf ImageMagick.tar.gz
Access the working directory:
cd ImageMagick-*
Configure disabling the "shared" option and prefix installed source files with the stow dir path:
./configure --disable-shared --prefix=/usr/local/stow/ImageMagick
Compile, install and check:
sudo make && sudo make install && sudo make check
Stow the ImageMagick package:
cd /usr/local/stow/
stow ImageMagick
Ensure the above delegates are present:
identify --version
Version: ImageMagick 7.1.0-4 Q16 x86_64 2021-07-17 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): freetype jbig jng jpeg lzma png tiff x xml zlib
Gnu Stow will make easier uninstalling the package if you need to re-install it from scratch:
cd /usr/local/stow/
stow -D ImageMagick #it will remove the symlinked soruce files inside ../lib, ../bin, etc.
rm -rf ImageMagick/
You've built your own imagemagick from source.
This is not an easy thing to do -- you need a lot of other packages for it to all work correctly (for example, you must install the headers for libjpeg and libexif if you want to process jpeg images), you'll need quite deep knowledge of file formats and file format libraries, you'll need to think carefully about security and which delegates you need, and then once you've built it, you'll need to maintain it.
Instead, it's almost always better to just use Ubuntu's built-in imagemagick. Simply enter:
apt install imagemagick
And it'll download and install a tested and working copy of imagemagick, and it'll automatically keep it up to date as bugfixes are issued. You should probably remove the imagemagick that you built to reduce confusion.
I would only build from source if I absolutely had to have a more recent version of a package than was in the package repository, and even then I'd think twice. Or even three times.

Linux Mint 17.2 screen resolution [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I am fresh new on linux and tring to connect on a TV
http://www.cnet.com/products/samsung-ln-s325d/specs/ using DVI.
Problem: The screen resolution isn't good :(
I've tried many things with the xrandr command, but in the end, the new mode just doesn't work (black screen).
Here is the terminal:
frank#frank-Mint ~ $ cvt 1366 768
# 1368x768 59.88 Hz (CVT) hsync: 47.79 kHz; pclk: 85.25 MHz
Modeline "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
frank#frank-Mint ~ $ xrandr --newmode "1368x768_60.00" 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
frank#frank-Mint ~ $ xrandr --addmode DVI-1 "1368x768_60.00"
From there,
frank#frank-Mint ~ $ xrandr --output DVI-1 --mode 1368x768_60.00
or system settings > Display >1368x768 (16:9)
just gives me a black screen saying the mode is not available
I have tried many other resolutions, but any custom resolutions do that.
Anyone have an idea?
thanks! :)
EDIT:
frank#frank-Mint ~ $ xrandr
Screen 0: minimum 320 x 200, current 1280 x 720, maximum 16384 x 16384
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DVI-0 disconnected (normal left inverted right x axis y axis)
DVI-1 connected primary 1280x720+0+0 (normal left inverted right x axis y axis) 160mm x 90mm
1280x720 60.0*+ 59.9
1920x1080i 60.1 60.0
720x480 60.0 59.9
640x480 60.0 59.9
1368x768_60.00 59.9
1024x768_60.00 59.9
The last 2 are added
Got it. Needed to upgrate graphic card driver lol
Try this:
xrandr --output DVI-1 --mode "1368x768_60.00"

ImageMagick SVG to PNG not colorizing

I have ImageMagick installed on my Mac OS, Linux 64bit (2 systems) and RedHat.
I have a simple SVG file with this content:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="100px" height="100px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
<g>
<rect x="15" y="15" style="fill:none;" width="70" height="70"/>
<path d="M85,0H15H0v15v70v15h15h70h15V85V15V0H85z M85,85H15V15h70V85z"/>
</g>
</svg>
When I convert it on MAC OSX, RedHat or even one of my Linux setup using:
convert -fill 'rgb(255,0,0)' image.svg test.png
it converts the file correctly i.e. it changes it color to red.
However, on other Linux setup it does not colorize it, but remains in black color.
On all of the systems I installed ImageMagick from source. All have same version. All gives "rsvg-convert" -o "%o" "%i" when I execute:
convert -list delegate | grep 'svg => '
But I don't know why one of my Linux setup it does not work well as expected.
Add -verbose to your convert command:
convert -verbose -fill 'rgba(255,0,0,0)' image.svg test.png
Then test again on each of your systems. Compare the output for each case.
-verbose reports in the terminal output which exact delegate command line will be run in the background to bring about a final format that ImageMagick can process itself.
For example, on my current system (OSX Mavericks), because I have a different setup from yours, my conversion doesn't fill red into the SVG, and I get to see this in the terminal:
"/opt/local/bin/inkscape" "/var/tmp/magick-31893m0w2-x4pHlPY" \
--export-eps="/var/tmp/magick-31893y4-KtfXirywn" \
--export-dpi="90,90" --export-background="rgb(100%,100%,100%)" \
--export-background-opacity="1" > \
"/var/tmp/magick-31893J8WlJy8Sn0uH" 2>&1
/var/tmp/magick-31893M9guCq3EvFL71 PNG 80x80 80x80+0+0 8-bit sRGB 351B 0.000u 0:00.000
/var/tmp/magick-31893y4-KtfXirywn PS 80x80 80x80+0+0 16-bit sRGB 351B 0.000u 0:00.000
img.svg=>/var/tmp/magick-31893y4-KtfXirywn PS 80x80 80x80+0+0 16-bit sRGB 351B 0.000u 0:00.000
img.svg=>out.png PS 80x80 80x80+0+0 8-bit sRGB 3c 463B 0.000u 0:00.000
[ghostscript library] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT \
-dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 \
"-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \
"-r72x72" -g80x80 "-sOutputFile=/var/tmp/magick-31893M9guCq3EvFL7%d" \
"-f/var/tmp/magick-31893VjGeCPBsW7zN" \
"-f/var/tmp/magick-31893OxqHgutvF5QZ"
As you can see, in my case there will be Inkscape as a delegate converting the SVG to EPS, then Ghostscript to convert the EPS to PNG (with alpha channel)....
Try this:
convert -fill 'rgb(255,0,0)' MSVG:test.svg test.png
It uses ImageMagick's own SVG internal renderer, MSVG, instead of the RSVG library. More info here: http://imagemagick.org/Usage/draw/#svg
However, MSVG is not a complete SVG converter, so some SVG files might not be rendered correctly.

Image magick: takes too much time at linux server

I am facing an issue with time taken by imagemagic to execute the commands on my server. I also tried to make thread control from 20(default) to 1 but, no improvements.
Here are some of the commands we fire and time took for them on server. Is there any way to reduce this execution time?
/usr/bin/convert source1.jpeg -resize 4518x3013! output.png
real 0m13.150s
user 0m18.320s
sys 0m2.029s
/usr/bin/convert output.png -crop 2408x3010+1053+0 +repage cropped.png
real 0m5.978s
user 0m5.043s
sys 0m0.881s
/usr/bin/convert destination.png -draw image over 564,564+2408+3010 'cropped.png' output.png
real 0m10.085s
user 0m11.160s
sys 0m1.710s
Updated Information
identify -version command output:
Version: ImageMagick 6.8.9-1 Q16 x86_64 2014-08-16 http://www.imagemagick.org
Copyright: Copyright ( c ) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib freetype gslib jng jpeg png ps tiff zlib
Server configuration:
OS version is centos 6
RAM 32GB
source1.jpeg(link)
First command executed with -bench 5 and returned below output.
Performance[1]: 5i 0.095ips 1.000e 90.970u 0:52.550
Performance[2]: 5i 0.104ips 0.522e 92.310u 0:48.110
Performance[3]: 5i 0.090ips 0.485e 93.420u 0:55.770
Performance[4]: 5i 0.086ips 0.474e 91.180u 0:58.230
Performance[5]: 5i 0.091ips 0.488e 94.850u 0:55.030
Thanks,
Sagar
Does this get you any faster?
convert input.png -quality 80% -resize 4518x3013! \
\( +clone -crop 2408x3010+1053+0 +repage \) \
-geometry +564+564 -composite output.png
For really fast PNG writing, use -quality 10 for drawings, -quality 11 for photos. This should cut your PNG-writing time by a factor of five.
The "quality" number doesn't affect image quality when writing a PNG. It only affects the compression effectiveness.

Imagemagick use-trimbox doesn't work at all

I'm desparately trying to convert PDF to JPG by Imagemagick (convert command) preserving trimbox.
I run following command (convert only first page).
convert -verbose -define pdf:use-trimbox=true "test_org.pdf[0]" cropped.jpg
Here is an output. Looks like imagemagick doesn't pass use-trimbox parameter to the ghostscript. May that be a reason? As at the moment converted image is mediabox size, not trimbox. Version of ImageMagick is 6.0.7, ghostscript GPL Ghostscript 8.64.
convert: **"gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 "-sDEVICE=bmpsep8" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-g652x935" "-r72x72" -dFirstPage=1 -dLastPage=1 "-sOutputFile=/tmp/magick-XXgTtZZG" "-f/tmp/magick-XXs4Kjq2" "-ftest_org.pdf".**
/tmp/magick-XXgTtZZG[0] BMP 652x935 PseudoClass 256c 2.3mb 0.050u 0:01
/tmp/magick-XXgTtZZG[1] BMP 652x935 PseudoClass 256c 2.3mb 0.040u 0:01
/tmp/magick-XXgTtZZG[2] BMP 652x935 PseudoClass 256c 2.3mb 0.020u 0:01
/tmp/magick-XXgTtZZG[3] BMP 652x935 PseudoClass 256c 2.3mb 0.010u 0:01
test_org.pdf PDF 652x935 652x935+0+0 DirectClass 2.3mb 0.040u 0:01
test_org.pdf PDF 652x935 652x935+0+0 DirectClass 2.3mb 0.040u 0:01
test_org.pdf=>cropped.jpg PDF 652x935 652x935+0+0 DirectClass 202kb 0.120u 0:01
You possibly have too old ImageMagick. Works fine in my case.
Version: ImageMagick 6.6.0-4 2010-11-16 Q16 http://www.imagemagick.org
-define pdf:use-trimbox=true makes convert invoke gs with -dUseTrimBox option, which I don't see in output provided by you. Consider updating ImageMagick.
Your ImageMagick 6.0.7 is more than 6 years old (dozens of releases back). Current is 6.7.0-9.
Your Ghostscript 8.64 is also more than 2 years old already (5 releases back). Current is 9.02.
My recommendation is to upgrade.
On my (Windows) system I have IM 6.7.0-8 and GS 9.02. Running -define pdf:use-trimbox=true works fine here and translates to a Ghostscript commandline parameter of -dUseTrimBox=true.
However (and this is important!): one should take into account, that for many practical example PDFs out there, TrimBox is undefined, or explicitely set to the same values as MediaBox. Both have the same effect: a -dUseTrimBox=true will not make any difference in the output to a -dUseTrimBox=false.

Resources