Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 382
Product
ImgWriter
Title
SoftArtisans ImgWriter: MergeWithImage Method vs. AddWatermark Method
Solution

There are two ways to use SoftArtisans ImgWriter tool for merging images. The first, and easier of the two, is to use the AddWatermark method, which doesn't give you as much control, but takes a lot of the guesswork out of merging images. The second is to use the MergeWithImage method, which gives you a lot of control over the placement and look of the image you are merging in.

AddWatermark Method

If you do not require as much control over the merged images and want to let ImgWriter do the work for you, use the AddWatermark method. AddWatermark has only one required parameter, the file name of the watermark image. All of AddWatermark's other parameters are optional.

AddWatermark(Watermark Source (required), [Position (optional)], [Opacity (optional)], [TransitionColor (optional)], [ShrinkToFit (optional)])

AddWatermark Parameters:

Watermark Source required Value can be a file name, an ADO Recordset Field, or an array of bytes
Position optional Defaults to saiCenterLeft
Opacity optional Defaults to 0.5 - 0 is transparent, 1 is opaque
TransitionColor optional Defaults to white or 16777215 or 0xFFFFFF
ShrinkToFit optional Defaults to True or 1

AddWatermark Position Constants (second parameter, optional):

saiTopMiddle = 0
saiCenterMiddle = 1
saiBottomMiddle = 2
saiTopLeft = 3
saiCenterLeft = 4
saiBottomLeft = 5
saiTopRight = 6
saiCenterRight = 7
saiBottomRight = 8

Use AddWatermark in your code:

<%
.
.
.
'--- Instantiate SoftArtisans ImgGen Component
Set objImageGen = Server.CreateObject("SoftArtisans.ImageGen")
'---
'--- Load existing image
objImageGen.LoadImage "c:\oldimage.jpg"
'---
'--- Add the image in 'watermark.bmp' using all defaults
objImageGen.AddWatermark "C:\temp\watermark.bmp"
'---
'--- Save new image
objImageGen.SaveImage saiFile, saiJPG, "c:\newimage.jpg"
.
.
.
%>
MergeWithImage Method

If you need more control over the merged images, use the MergeWithImage method. MergeWithImage has five required parameters to give you explicit control and flexibility over where the merged image appears in the original image.

MergeWithImage(X-axis coordinate (required), Y-axis coordinate (required), Image Source (required), Opacity (required), TransColor (required), [ShrinkToFit (optional)])

MergeWithImage Parameters:

X-axis coordinate required Distance, in pixels, between the left border of the main image and the left border of the image to merge with the main image
Y-axis coordinate required Distance, in pixels, between the top border of the main image and the top border of the image to merge with the main image
Image Source required File path and name of the image to merge with the main image
Opacity required At 0, the merged image is completely transparent
At 1, it is completely opaque
TransColor required The color of the top (merged) image that will be made transparent when Opacity is set to a value less than 1
ShrinkToFit optional Defaults to true or 1

Use MergeWithImage in your code:

<%
.
.
.
'--- Instantiate SoftArtisans ImgGen Component
Set objImageGen = Server.CreateObject("softartisans.ImageGen")
'---
'--- Load existing image
objImageGen.LoadImage "c:\oldimage.jpg"
'---
'--- Merge another image in with the loaded image
objImageGen.MergeWithImage 50, 300, "c:\temp\anotherimage.jpg", 0.2, 1
'---
'--- Save new image
objImageGen.SaveImage saiFile, saiJPG, "c:\mergedimage.jpg"
.
.
.
%>
Created : 12/1/2002 12:00:00 AM (last modified : 9/6/2002 11:05:44 AM)
Rate this article!
Comments