Note: all scripts examples included in these Web pages are absolutely free. You can copy, use, and modify these scripts anyway you want. The scripts are published without warranty of any kind.
|
|
File frame1.vbs
This script reads mask image from file. Two shotgraph objects are used. |
Set g = CreateObject("shotgraph.image")
Set gg = CreateObject("shotgraph.image")
' Maximal dimensions for thumbnail
xsize = 150
ysize = 150
' Files
source = "original.jpg"
mask = "frame_ellipse.gif"
new_file = "result.jpg"
itype = g.GetFileDimensions(source,width,height)
if itype = 0 then
Wscript.echo "Image is not recognized"
Wscript.Quit(0)
end if
' Calculate thumbnail dimensions (xset x yset)
if width/xsize > height/ysize then
xset=xsize
yset=height*xsize\width
else
yset=ysize
xset=width*ysize\height
end if
g.CreateImage xset,yset,8
gg.CreateImage xset,yset,8
' Resize source image
g.InitClipboard width,height
g.SelectClipboard True
g.ReadImage source,pal,0,0
g.Stretch 0,0,xset,yset,0,0,width,height,"SRCCOPY","HALFTONE"
g.SelectClipboard False
g.Sharpen
' Read resized image to primary imagespace of gg object
gg.ReadImage g,palette,0,0
' Resize mask image
g.GetFileDimensions mask,fwidth,fheight
g.InitClipboard fwidth,fheight
g.SelectClipboard True
g.ReadImage mask,palette,0,0
g.Stretch 0,0,xset,yset,0,0,fwidth,fheight,"SRCCOPY","COLORONCOLOR"
g.SelectClipboard False
' Read resized mask image to secondary imagespace of gg object
gg.InitClipboard xset,yset
gg.SelectClipboard True
gg.ReadImage g,palette,0,0
' Copy making black color transparent
gg.TransparentCopy 0,0,xset,yset,0,0,Array(0,0,0),0,50
gg.SelectClipboard False
gg.JpegImage 90,0,new_file
|
|
File frame2.vbs
This script draws mask ellipse on secondary imagespace. One shotgraph object is used. |
Set g = CreateObject("shotgraph.image")
' Maximal dimensions for thumbnail
xsize = 150
ysize = 150
' Files
source = "E:\works\shot\site\img\original.jpg"
feather = "E:\works\shot\site\img\frame_ellipse.gif"
new_file = "result.jpg"
itype = g.GetFileDimensions(source,width,height)
if itype = 0 then
Wscript.echo "Image is not recognized"
Wscript.Quit(0)
end if
' Calculate thumbnail dimensions (xset x yset)
if width/xsize > height/ysize then
xset=xsize
yset=height*xsize\width
else
yset=ysize
xset=width*ysize\height
end if
g.CreateImage xset,yset,8
' Resize source image
g.InitClipboard width,height
g.SelectClipboard True
g.ReadImage source,pal,0,0
g.Stretch 0,0,xset,yset,0,0,width,height,"SRCCOPY","HALFTONE"
g.SelectClipboard False
g.Sharpen
' Draw black ellipse on white background in the secondary imagespace
g.InitClipboard xset,yset
g.SelectClipboard True
g.SetColor 0,255,255,255
g.SetColor 1,0,0,0
g.SetBgColor 0
g.FillRect 0,0,xset,yset
g.SetBgColor 1
g.SetDrawColor 1
g.Ellipse xset\10,yset\10,xset-xset\10,yset-yset\10
' Copy making black color transparent
g.TransparentCopy 0,0,xset,yset,0,0,Array(0,0,0),0,50
g.SelectClipboard False
g.JpegImage 90,0,new_file
|