0

i am using MagickImage to change Dpi of an image but it doesn't work

MagickNET.SetGhostscriptDirectory(System.IO.Directory.GetCurrentDirectory());
        MagickReadSettings settings = new MagickReadSettings();
        settings.Density = new Density(72, 72);
        using (MagickImage image = new MagickImage(@"C:\Users\User\AppData\Local\Temp\Chapter 4\Figure 4-1.tif", settings))
        {
            image.Write(@"C:\Users\User\AppData\Local\Temp\Chapter 4\Figure 4-1.jpg");
        }

or if this doesn't work

is there a way to resize the image like what the photoshop did

example the image with 300 dPi have a w1200xh788 size

and using photoshop. i changed the dpi to 72 and it creates a w288xh189

how can i programmatically do this. thank you

pdf asker
  • 59
  • 2
  • 11

1 Answers1

0

You can do as following :

using System;

    namespace ImageDPI
    {
        public class Program
        {
            public static void Main(string[] args)
            {
                int Aw, Ah, Rw, Rh, Adpi, Rdpi;

                Aw = 1200;
                Ah = 788;

                Adpi = 300;
                Rdpi = 72;

                Rw= (Aw * Rdpi) / Adpi;
                Rh= (Ah * Rdpi) / Adpi;

                Console.WriteLine(Rw);
                Console.WriteLine(Rh);


            }
        }
    }
Chirag
  • 324
  • 2
  • 4
  • 27