How to apply shadow to all side of image

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
durga1208
Posts: 14
Joined: 2016-05-05T02:00:57-07:00
Authentication code: 1151

How to apply shadow to all side of image

Post by durga1208 » 2016-05-05T02:04:40-07:00

I am able to generate shadow with following code but shadow generating only right bottom. I want shadow all sides of images.

image2.Shadow(5,5, 10, new Percentage(10),MagickColors.WhiteSmoke);

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: How to apply shadow to all side of image

Post by dlemstra » 2016-05-16T06:58:01-07:00

The next version of Magick.NET will include a fixed version of the Shadow method. It now automatically draws the shadow behind the image. This will prevent you from being able to draw a shadow on all sides. After the fix only the shadow will be drawn and you will have to draw your image over if with Composite yourself.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

durga1208
Posts: 14
Joined: 2016-05-05T02:00:57-07:00
Authentication code: 1151

Re: How to apply shadow to all side of image

Post by durga1208 » 2016-05-21T04:30:59-07:00

Do you have any information on next release.

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: How to apply shadow to all side of image

Post by dlemstra » 2016-05-21T04:33:44-07:00

I published it a an hour ago :)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

ankit1931
Posts: 2
Joined: 2016-05-21T05:53:54-07:00
Authentication code: 1151

Re: How to apply shadow to all side of image

Post by ankit1931 » 2016-05-21T05:58:54-07:00

How to apply shadow to all side of image?
when i am using this code "image.Shadow(5, 5, 10, new Percentage(10), MagickColors.DarkRed);"
so it is creating the shadow of the content of the image.
but i need shadow of all 4 sides of image?

durga1208
Posts: 14
Joined: 2016-05-05T02:00:57-07:00
Authentication code: 1151

Re: How to apply shadow to all side of image

Post by durga1208 » 2016-05-21T06:13:19-07:00

Can you please provide sample code of Shadow. I am using AnyCPU version.

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: How to apply shadow to all side of image

Post by dlemstra » 2016-05-21T07:40:58-07:00

Can you share a sample image where you want to add a shadow to?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

durga1208
Posts: 14
Joined: 2016-05-05T02:00:57-07:00
Authentication code: 1151

Re: How to apply shadow to all side of image

Post by durga1208 » 2016-05-21T11:45:09-07:00

I am generating image from pdf and trying to apply shadow.

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: How to apply shadow to all side of image

Post by dlemstra » 2016-05-21T12:20:28-07:00

If you add a link to the PDF or image I can see what you are trying to accomplish.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

durga1208
Posts: 14
Joined: 2016-05-05T02:00:57-07:00
Authentication code: 1151

Re: How to apply shadow to all side of image

Post by durga1208 » 2016-05-22T09:03:21-07:00

I am trying to generate image with drop shadow with all sides from https://sitecorepractice.files.wordpres ... m_0613.pdf first page.

User avatar
fmw42
Posts: 25388
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to apply shadow to all side of image

Post by fmw42 » 2016-05-22T18:58:06-07:00

try the equivalent of -shadow 100x5+0+0 where 100 is darkest and 5 is distance. The +0+0 means not to offset in any direction.

Code: Select all

convert inputimage \
\( +clone -background black -shadow 100x5+0+0 \) +swap \
-background none -layers merge +repage \
outputimage

ankit1931
Posts: 2
Joined: 2016-05-21T05:53:54-07:00
Authentication code: 1151

Re: How to apply shadow to all side of image

Post by ankit1931 » 2016-05-23T02:55:44-07:00

Can u please provide magick.net code for the same?

User avatar
fmw42
Posts: 25388
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to apply shadow to all side of image

Post by fmw42 » 2016-05-23T11:12:10-07:00

ankit1931 wrote:Can u please provide magick.net code for the same?
Sorry, I do not use magick.net

durga1208
Posts: 14
Joined: 2016-05-05T02:00:57-07:00
Authentication code: 1151

Re: How to apply shadow to all side of image

Post by durga1208 » 2016-05-25T05:11:01-07:00

Hi dlemstra, can you please provide sample code for shadow.

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: How to apply shadow to all side of image

Post by dlemstra » 2016-05-29T02:20:52-07:00

Sorry for getting back to you this late but below is a translation of Fred his commands. It is not an exact translation but it should help you.

Code: Select all

using (MagickImageCollection pdfDocument = new MagickImageCollection())
{
  pdfDocument.Read("lcp-001_vectralcpprecmoldtg_am_0613.pdf");
  for (int i = 0; i < pdfDocument.Count; i++)
  {
    var backgroundColor = MagickColors.Black;
    if (pdfDocument[i].ColorSpace == ColorSpace.CMYK)
      backgroundColor = new MagickColor(0, 0, 0, Quantum.Max, Quantum.Max);

    using (MagickImageCollection images = new MagickImageCollection())
    {
      MagickImage shadow = pdfDocument[i].Clone(); // +clone
      shadow.Shadow(0, 0, 5, (Percentage)90, backgroundColor); // -background black -shadow 100x5+0+0
      shadow.BackgroundColor = MagickColors.None; // -background none
      // +swap changes the order of the images we just add them in a different order
      images.Add(shadow);
      images.Add(pdfDocument[i].Clone());
      using (MagickImage merged = images.Merge()) // -layers merge
      {
        merged.Write($"d:\pdf_{i}.png");
      }
    }
  }
}
The background color part is necessary because your PDF file appears to be CMYK and you will need to use a different color then.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Post Reply