Quantcast
Channel: magick Discussions Rss Feed
Viewing all 3693 articles
Browse latest View live

New Post: Drawing text

$
0
0
You can reset the page (repage) like this:
image.Page = new MagickGeometry(0, 0);

New Post: Converting EMF to PNG

$
0
0
At this moment you need an external executable called emfplus.exe (http://www.imagemagick.org/download/contrib/EMFPlus.tar.gz) in your bin directory. I am working on trying to integrate this within ImageMagick but I cannot give you an ETA when this will be done. Your example above can be rewritten like this:
  MagickReadSettings settings = new MagickReadSettings();
  settings.Density = new MagickGeometry(288, 288);
  using (MagickImageCollection images = new MagickImageCollection("image.emf", settings))
  {
    using (MagickImage image = images.Flatten())
    {
      image.Quality = 100; // You are missing a 1?
      image.ColorSpace = ColorSpace.RGB;
      image.Resize(0.5); // implicit cast to Percentage
      image.ColorSpace = ColorSpace.sRGB;
      image.Write("image.png");
    }
  }

New Post: Converting EMF to PNG

$
0
0
Thanks for your quick reply.

For quality - I was trying to do it as it's mentioned in docs http://www.imagemagick.org/Usage/formats/#png . Did I get it wrong?
PNG compression

When used with PNG output, quality is regarded as two decimal figures. The first digit (tens) is the zlib compression level, 1-9. However if a setting of '0' is used you will get Huffman compression rather than 'zlib' compression, which is often better! Weird but true!
The second digit is the PNG data encoding filtering (before it is comressed) type: 0 is none, 1 is "sub", 2 is "up", 3 is "average", 4 is "Paeth", and 5 is "adaptive". So for images with solid sequences of color a "none" filter (-quality 00) is typically better. For images of natural landscapes an "adaptive" filtering (-quality 05) is generally better.

New Post: Converting EMF to PNG

$
0
0
If you want to specify it like that you need to use the SetDefine method in Magick.NET:
using (MagickImage image = images.Flatten())
  {
    image.ColorSpace = ColorSpace.RGB;
    image.Resize(0.5); // implicit cast to Percentage
    image.ColorSpace = ColorSpace.sRGB;
    image.SetDefine(MagickFormat.Png, "compression-strategy", "0");
    image.SetDefine(MagickFormat.Png, "compression-filter", "0");
    image.Write("image.png");
  }

New Post: Converting EMF to PNG

New Post: Minimize file size of embedded images in PDF output

$
0
0
I read in two PDF files as image collections and then compare the sheets to show what has changed. When I do it at the command line with imagemagick and ghostscript I get file sizes about 10 times smaller than the output I get with Magick.NET.
I'm wondering how I control the compression of the embedded images in a ghostscript PDF file.

New Post: Minimize file size of embedded images in PDF output

$
0
0
Can you post an example of what you are doing on the command line?

New Post: Minimize file size of embedded images in PDF output

$
0
0
Here's the code using Magick.NET
            using (MagickImageCollection new_images = new MagickImageCollection(),
                old_images = new MagickImageCollection(),
                diff_images = new MagickImageCollection())
            {
                new_images.Read(@"C:\Users\username\Pictures\projects\pdfcompare\new_drawing.pdf", settings);
                old_images.Read(@"C:\Users\username\Pictures\projects\pdfcompare\old_drawing.pdf", settings);
                
                int i = 1;
                int j = 1;
 
                foreach (MagickImage image in new_images)
                {
                    image.Alpha(AlphaOption.Opaque);
                    i++;
                }
                foreach (MagickImage image in old_images)
                {
                    image.Alpha(AlphaOption.Opaque);
                    j++;
                }
                
                // Compare both new and old
                if (new_images.Count == old_images.Count )
                {
                    for (int shtNum = 0; shtNum < new_images.Count; shtNum++)
                    {
                        MagickImage diff_image = new MagickImage();
                        MagickImage new_image = new_images.ElementAt(shtNum);
                        MagickImage old_image = old_images.ElementAt(shtNum);
                        new_image.Compare(old_image, Metric.FuzzError, diff_image);
                        diff_images.Add(diff_image);
                    }
                }
                // Output image diff
                diff_images.Write(@"C:\Users\username\Pictures\projects\pdfcompare\output\diff-drawings" + ".pdf");
Here's the command line equivalent:

First I read in the PDFs and output pngs
gswin64c.exe -q -dQUIET -dBATCH -dNOPAUSE -NOPROMPT -sDEVICE=png16m -r150 -sOutputFile="sheet-%d.png" "input.pdf"
Then I do the comparison and output the pdf
convert.exe sheet-1.png sheet-2.png output.pdf
I'm guessing the command line is smaller because I'm turning some pngs into a pdf. I'm not sure what file format gets wrapped by the pdf in Magick.NET + ghostscript. Could also be that I don't have an alpha channel in the command line version and I do with the code.

New Post: Minimize file size of embedded images in PDF output

$
0
0
I am also not sure what the format of the image is. You could check the Format property of diff_image. Have you tried setting the Format to MagickFormat.Png?

New Post: EXIF parser always return 0 for Short value ToString

$
0
0
All Short values in the EXIF parser are returned as 0 when ToString is used. I'm looking through the source, but haven't put my finger on it yet. This was noticed when I tried to read Orientation so we can store the image's rotation in the database. It was 0, but then I noticed all non-array Short values return 0 also. Still investigating arrays of Short. Any thoughts on what it might be, or if I should use another method to get Short converted to string?

If you need an image to test on let me know, but it's easy enough if you have a phone that sets the Orientation tag.

Thanks!

New Post: EXIF parser always return 0 for Short value ToString

$
0
0
Also, just to be clear, this happens with ExifValue.ToString and ExifValue.Value.ToString

New Post: EXIF parser always return 0 for Short value ToString

$
0
0
Can you post a link to one of your images? I recently fixed a bug with short values in ImageMagick with tiff images. Does this error happen with a specific format?

P.s Next time feel free to edit your post instead of posting a new message.

New Post: EXIF parser always return 0 for Short value ToString

$
0
0
This is just a JPG that I took with my iPhone. I can't say if it's format related or not:

photo.jpg

Sorry for the double-post... I don't post that often. :-)

New Post: EXIF parser always return 0 for Short value ToString

$
0
0
This seems to be an Endianness bug. I will create a work item to resolve this issue.

New Post: EXIF parser always return 0 for Short value ToString

$
0
0
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.

New Post: Minimize file size of embedded images in PDF output

$
0
0
Here's the format of the diff_image to start with: {Pdf: Portable Document Format (+R+W+M)}. I had already tried converting the images to png on import, but it didn't have much of an effect. Not sure why I didn't think of converting diff_image as well.

Here's what I did that cut the file size of the pdf in half:
                        diff_image.HasAlpha = false;
                        diff_image.Format = MagickFormat.Png;
                        diff_image.Quality = 95;
                        diff_images.Add(diff_image);
The original pdf was 2.53MB and after the above addition it became 1.38MB. However the odd part is when I changed the image quality to 5 the pdf was the same 1.38MB. I also output the png diff_image by itself and compared the difference between the output at quality=5 and quality=95. The quality 5 was 674KB and quality 95 was 167KB. So the pdf shrunk by 45% and the png shrunk by 75%. I'm wondering why the png shrunk so much, but the pdf didn't.

Thanks for the guidance on converting the output to png.

New Post: Minimize file size of embedded images in PDF output

$
0
0
Maybe the quality operation does not influence the size of the resulting pdf? Will you get the 2.53MB size when you omit the 'diff_image.Format = MagickFormat.Png' statement?

Does your resulting pdf from the command line has a size of only 260kB? Are you sure both pdf's are created from images with the same dimmension and format?

The quality operator for png does not work the same as for jpeg images. It is used to set the compression level of the image. You can read the following post to see how it works: http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=24134#p103040

New Post: Minimize file size of embedded images in PDF output

$
0
0
You're right the quality doesn't affect the output size of the PDF. It does affect the output size of the pngs. It is just the setting of HasAlpha=false that shrinks the pdf file output. I'll check out the command line after the Christmas gifts get opened :-).

New Post: Minimize file size of embedded images in PDF output

$
0
0
I did some testing with the command line side and the magick.net isn't far off. I ended up getting 1.06MB with the command line instead of 1.38MB with Magick.NET.
The starting pngs for the cli generated pdf were 199KB and 86.7KB which is about a third of the final pdf. I might try using one bit images instead of grayscale to see what I can squeeze out. I just got a little freaked out when the 6 page D size drawing comparisons were getting close to 11MB.

Thanks for the reality check. Wish there was a way to have the PDF be just twice the size of the pngs. Makes me think the pngs are uncompressed when they're stored in the pdf.

New Post: Minimize file size of embedded images in PDF output

Viewing all 3693 articles
Browse latest View live