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 »

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: 1570
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 »

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 »

Do you have any information on next release.
User avatar
dlemstra
Posts: 1570
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 »

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 »

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 »

Can you please provide sample code of Shadow. I am using AnyCPU version.
User avatar
dlemstra
Posts: 1570
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 »

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 »

I am generating image from pdf and trying to apply shadow.
User avatar
dlemstra
Posts: 1570
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 »

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 »

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: 25562
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 »

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 »

Can u please provide magick.net code for the same?
User avatar
fmw42
Posts: 25562
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 »

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 »

Hi dlemstra, can you please provide sample code for shadow.
User avatar
dlemstra
Posts: 1570
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 »

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