Page 1 of 2

Converting EMF to JPG

Posted: 2012-03-24T17:40:04-07:00
by Dahak
New to using ImageMagick...

Trying to convert an EMF to JPG (on a Windows box). No complex conversions, just trying, without success, to get the output resolution I want.

A simple default convert like CONVERT SRC.EMF DST.JPG runs the conversion to an apparently 'default' size of 3997x2000.

My goal is to output to a final resolution of 10K, 15K or even 20K pixel width.

Since EMF doesn't normally seem to have size information, I've tried issuing -GEOMETRY "10000x5000" and/or -DENSITY "10000x5000". In all cases I wind up with output images of those dimensions, but simply scaled upward, as if the source image was rasterized at the 'default' 3997x2000 and then scaled.

I was under the impression that -DENSITY would affect the dimensions of the rasterizing of the source image.

What would be the proper way to do what I want.

BTW: since it is a vector format, I can zoom in to view the fine details with Illustrator that are below the level of resolution on the output bitmapped image. It is those fine details I'm trying to preserve.

Re: Converting EMF to JPG

Posted: 2012-03-24T18:18:21-07:00
by fmw42
put -density XXX before the image and right after "convert". But note that density is in dots per inch (pixels per inch). So you need to adjust the density value to produce the pixel dimensions you want. Nominal values are 72 dpi.

Re: Converting EMF to JPG

Posted: 2012-03-24T19:12:15-07:00
by Dahak
fmw42 wrote:put -density XXX before the image and right after "convert". But note that density is in dots per inch (pixels per inch). So you need to adjust the density value to produce the pixel dimensions you want. Nominal values are 72 dpi.
Thanks for the quick response. I hadn't realized that the parameters were position-sensitive.

I was also wondering why I was allowed to specify density as an area.

First attempt with new density took about 20 minutes to abort with 'Maximum supported image dimension is 65500'.

I thought there was support for large-format images? I'll be more conservative in my next try. Thanks again for the help.

Re: Converting EMF to JPG

Posted: 2012-03-24T19:26:40-07:00
by fmw42
Density allow the x dpi to be different from the y dpi.

IM is forgiving with position of most parameters. The correct IM 6 syntax is to have the image read first, then the parameters. However, for vector files you have to specify things like density and colorspace before reading the image so it knows what to do with the fact that there is no density/resolution value for vector files.

see

http://www.imagemagick.org/script/comma ... a6#density

"The default unit of measure is in dots per inch (DPI). The -units option may be used to select dots per centimeter instead.
The default resolution is 72 dots per inch, which is equivalent to one point per pixel"

http://www.imagemagick.org/Usage/basics/#cmdline


Specify a smaller density value to keep your image size small.

Re: Converting EMF to JPG

Posted: 2012-03-25T08:47:38-07:00
by Dahak
fmw42 wrote:see

http://www.imagemagick.org/script/comma ... a6#density

"The default unit of measure is in dots per inch (DPI). The -units option may be used to select dots per centimeter instead.
The default resolution is 72 dots per inch, which is equivalent to one point per pixel"

http://www.imagemagick.org/Usage/basics/#cmdline

Specify a smaller density value to keep your image size small.
I had been reading the -GEOMETRY and -RESAMPLE sections and must have convinced myself that -DENSITY used the same type of argument.

So far, test with convert -density "150" source.emf dest5.jpg or convert -density "300" source.emf dest6.jpg yield output files of the same size with the same dot pitch (in my case 4001x2000).

I tried it with a -RESAMPLE before the output filename and it ran all night and I CTRL-C'd out of it just a few minutes ago.

I just tried it with -GEOMETRY "10000x5000" on the output side and got the simple upscale. So far, -DENSITY doesn't seem to be affecting the rasterization process for me.

Re: Converting EMF to JPG

Posted: 2012-03-25T11:34:30-07:00
by fmw42
convert -density "150" source.emf dest5.jpg or convert -density "300" source.emf dest6.jpg
As EMF is a vector format, these two commands should produce files with different widthxheight dimensions. The first should have a resolution of 150 dpi and the second should be 300 dpi.

Look at the verbose information from the two output files.

identify -verbose dest5.jpg

The geometry listed will be widthxheight+0+0

The resolution listed will be 150x150 (see units for dpi)

See if the widthxheight is different in each case and if the resolution is 150 in the first and 300 in the second.

If not, then you should post a link to your EMF image so some one else can test.

What version of IM are you using? If not current, perhaps you should upgrade.

Re: Converting EMF to JPG

Posted: 2012-03-25T16:40:58-07:00
by Dahak
fmw42 wrote:
convert -density "150" source.emf dest5.jpg or convert -density "300" source.emf dest6.jpg
As EMF is a vector format, these two commands should produce files with different widthxheight dimensions. The first should have a resolution of 150 dpi and the second should be 300 dpi.

Look at the verbose information from the two output files.

identify -verbose dest5.jpg

The geometry listed will be widthxheight+0+0

The resolution listed will be 150x150 (see units for dpi)

See if the widthxheight is different in each case and if the resolution is 150 in the first and 300 in the second.

If not, then you should post a link to your EMF image so some one else can test.

What version of IM are you using? If not current, perhaps you should upgrade.
First: the version I'm running is, I believe, the latest (I uninstalled my old version and upgraded it yesterday): Version: ImageMagick 6.7.6-1 2012-03-14 Q16 (running on 32-bit Windows XP). I experienced the same issue with the older v6 I had installed previously.

I completely agree with you on what -IDENTIFY should be reporting, but what I actually get seems to be different.

I re-ran the conversion samples I listed above against the same source file, the relevant details are:

Image: dest5.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 4001x2000+0+0
Resolution: 150x150
Print size: 26.6733x13.3333


and

Image: dest6.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 4001x2000+0+0
Resolution: 300x300
Print size: 13.3367x6.66667


As you can see, it reports the density as different, but the dot counts are the same. My goal, of course, is to get the dot counts up to a point where zooming in can return readable details.

The image is a global map made by a friend with quite a bit of detail at the local level that shows as so much blurred mush at the paltry(!) 4000x2000 dot level.

As for providing the file for testing, I may not be able to do so. (Or, not that image.) It's sort of proprietary information, although my goal is to post the JPG version of the map on my site, I don't think my friend would want the vector version released. I'll drop him a note.

BTW, thanks for the links. The one on the command line demonstrated that I was thinking 'UNIX command line' for the parameters, where they altered the switch handling in the more recent versions.

Re: Converting EMF to JPG

Posted: 2012-03-25T17:44:06-07:00
by fmw42
can you post a non-proprietary text example that shows the same problem?

Re: Converting EMF to JPG

Posted: 2012-03-25T18:06:51-07:00
by Dahak
fmw42 wrote:can you post a non-proprietary text example that shows the same problem?
I'm not sure what you mean by a text example.

The final output image will be posted online, I just don't see him wanting the vector-based version being posted.

I've asked him if his generating program can export a portion of the map that he would be comfortable allowing being posted for testing.

What I'm actually running, as I type this, is a conversion after I've used Illustrator to convert the EMF to EPS as the source format.

My first test with an AI file errorred. My first test with an EPS also errorred, but generated an output file at 2108x1185 pixels, of all things.

I'm running it now with a -RESAMPLE at 10000x5000 to see what happens.

Re: Converting EMF to JPG

Posted: 2012-03-25T18:57:18-07:00
by fmw42
I'm not sure what you mean by a text example.
Sorry, typo, I meant test not text.

Re: Converting EMF to JPG

Posted: 2012-03-25T19:13:56-07:00
by Dahak
fmw42 wrote:Sorry, typo, I meant test not text.
No problem. Working on getting one.

It isn't so much that the 'information' is proprietary, just that I don't think he'd want such an easily editable version to be publicly available.

Re: Converting EMF to JPG

Posted: 2012-03-26T16:42:49-07:00
by Dahak
fmw42 wrote:
I'm not sure what you mean by a text example.
Here's http://www.thefifthimperium.com/images/detail.emf a section of the map he ran off for me as a stand-alone file. It represents about 15-20% of the overall map.

This is a smaller segment that a quick test shows similar behavior, but Windows XP says it has dimensions of 5001x2334, even though EMF is supposed to be dimensionless, which is the size that IM gives me when I try a simple conversion of the file, like convert -density "100" detail.emf detail1.jpg

Changing the value of -DENSITY has no apparent effect.

Thanks for all your help.

Re: Converting EMF to JPG

Posted: 2012-03-26T17:46:17-07:00
by fmw42
identify -verbose detail.emf
identify: no decode delegate for this image format `detail.emf' @ error/constitute.c/ReadImage/532.

Unfortunately, I am not on Windows and it appears that I would need some delegate library to handle emf format, which I do not have nor do I know where to get it. Perhaps it comes with the Windows IM install. So one of the Windows users or IM developers will likely have to test this for you.

In fact, even Photoshop will not display this image.

Re: Converting EMF to JPG

Posted: 2012-03-26T19:14:56-07:00
by Dahak
fmw42 wrote:In fact, even Photoshop will not display this image.
Oddly, Adobe Illustrator will read it in, but I always seem to max out at about 8000x4000 pixels when exporting to JPG - not enough to resolve the smaller labels, and his northern continent has a ton of fine detail.

That's why I'm trying IM.

I've also tried exporting from Illustrator to EPS and AI, but IM chokes on them.

Thanks for taking the time to look at my problem. It's always possible the file-generator has somehow malformed the image, in some way.

Re: Converting EMF to JPG

Posted: 2012-03-26T19:29:49-07:00
by Dahak
fmw42 wrote:identify -verbose detail.emf
identify: no decode delegate for this image format `detail.emf' @ error/constitute.c/ReadImage/532.
I figured I'd check: it's probably a Windows thing.

I got this:

Code: Select all

Image: \temp\work\detail.emf
  Format: EMF (Windows WIN32 API rendered Enhanced Meta File)
  Class: DirectClass
  Geometry: 5001x2334+0+0
  Resolution: 47.24x47.24
  Print size: 105.864x49.4073
  Units: PixelsPerCentimeter
  Type: PaletteMatte
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 1-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 129.71 (0.508668)
      standard deviation: 18.68 (0.0732548)
      kurtosis: 42.2597
      skewness: 3.93621
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 248.591 (0.974867)
      standard deviation: 39.8104 (0.156119)
      kurtosis: 34.8148
      skewness: -6.06346
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 92.6394 (0.363292)
      standard deviation: 122.283 (0.479539)
      kurtosis: -1.66944
      skewness: 0.570175
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 254.921 (0.999691)
      standard deviation: 4.48195 (0.0175763)
      kurtosis: 3231.02
      skewness: 56.8597
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 117.755 (0.461784)
      standard deviation: 65.0133 (0.254954)
      kurtosis: 8.19091
      skewness: 0.716539
  Alpha: none   #00000000
  Colors: 14
  Histogram:
     38001: (  0,  0,  0,255) #000000 black
      3607: (  0,  0,  0,  0) #00000000 none
      2151: (  0,  0,255,255) #0000FF blue
      4391: (  0,106, 50,255) #006A32 srgba(0,106,50,1)
      7935: (128,  0,  0,255) #800000 maroon
     42230: (128,  0, 64,255) #800040 srgba(128,0,64,1)
     18256: (128,  0,128,255) #800080 purple
      1850: (128, 64,  0,255) #804000 srgba(128,64,0,1)
   7153668: (128,255,  0,255) #80FF00 srgba(128,255,0,1)
     10384: (128,255,128,255) #80FF80 srgba(128,255,128,1)
   4184131: (128,255,255,255) #80FFFF srgba(128,255,255,1)
    177071: (255,  0,  0,255) #FF0000 red
       312: (255,128,  0,255) #FF8000 srgba(255,128,0,1)
     28347: (255,255,255,255) #FFFFFF white
  Rendering intent: Perceptual
  Gamma: 0.45455
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Interlace: None
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Compose: Over
  Page geometry: 5001x2334+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2012-03-26T22:26:05-04:00
    date:modify: 2012-03-26T22:26:07-04:00
    png:cHRM                 : chunk was found (see Chromaticity, above)
    png:gAMA                 : gamma=0.45455 (See Gamma, above)
    png:IHDR.bit_depth       : 8
    png:IHDR.color_type      : 6
    png:IHDR.interlace_method: 0
    png:IHDR.width,height    : 5001, 2334
    png:pHYs                 : x_res=4724, y_res=4724, units=1
    png:sRGB                 : intent=0 (See Rendering intent)
    signature: 56efba52f4bd0f86c297e7de86ae1db972857d0ab4d0f2af3b495f97b04213b7
  Artifacts:
    filename: \temp\work\detail.emf
    verbose: true
  Tainted: False
  Filesize: 458KB
  Number pixels: 11.67M
  Pixels per second: 46.69MB
  User time: 0.219u
  Elapsed time: 0:01.250
  Version: ImageMagick 6.7.6-1 2012-03-14 Q16 http://www.imagemagick.org