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

New Post: Writing to an already open stream?

$
0
0
Aren't you missing a step in the example above? Step 5 calls Merge of object2 but MagickImage does not contain a Merge method. You probably created a MagickImageCollection at some point.

The reason you are not seeing the watermark is because you are writing two images to the stream instead of only one. An image looks something like this:
+------------------+
| Header of image  |
| +--------------+ |
| | Size of data | |
| +--------------+ |
+------------------+
| Image data       |
+------------------+
If your image contains more data then specified in the header it is considered to be garbage. Some image readers will raise an error but most readers will just ignore the rest after the 'Image data' block.

You should only write the result of the Merge method to the destinationStream.
using (MagickImageCollection images = new MagickImageCollection())
{
  images.Add("image.png");
  images.Add("watermark.png");
  using (MagickImage result = images.Merge())
  {
    result.Write(destinationStream);
  }
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>