NmagemanCOM

INDEX

NmagemanCOMとは?

NmagemanCOMは画像を扱うことができるCOMライブラリです。

以下のようなことが可能です。

概要

以下に簡単な例を示します。

Sample.vbs

'//--- '// ex1: Image is in file. set oNmageman = createobject("NmagemanCOM") if oNmageman.Load("sample.jpg") then oNmageman.Width = 100 '// width to 100px (keep ratio) oNmageman.Save("sample.out.jpg") end if '//--- '// ex2: Image is in stream. set oNmageman = createobject("NmagemanCOM") set oStreamIN = createobject("ADODB.Stream") '{ oStreamIN.open oStreamIN.type = 1 oStreamIN.loadFromFile "sample.jpg" '} set oStreamOUT = createobject("ADODB.Stream") '{ oStreamOUT.open oStreamOUT.type = 1 '} if oNmageman.Load(oStreamIN) then oNmageman.Width = 100 '// | oNmageman.Height = 100 '// | box convertion with 100*100 oNmageman.Format = 13 '// 13: PNG oNmageman.Save(oStreamOUT) oStreamOUT.saveToFile "sample.out2.png", 2 end if '//--- '// ex3: Metadata access set oNmageman = createobject("NmagemanCOM") if oNmageman.Load("metadata.jpg") then set oMetadata = oNmageman.Metadata(1) '// 1: EXIF_MAIN if not oMetadata is nothing then for each sName in oMetadata wscript.echo sName & " : " & oMetadata(sName): next end if wscript.echo "--" set oMetadata = oNmageman.Metadata(2) '// 2: EXIF_EXIF if not oMetadata is nothing then for each sName in oMetadata wscript.echo sName & " : " & oMetadata(sName): next end if wscript.echo "--" set oMetadata = oNmageman.Metadata(3) '// 3: EXIF_GPS if not oMetadata is nothing then for each sName in oMetadata wscript.echo sName & " : " & oMetadata(sName): next end if wscript.echo "--" end if '//--- '// ex4: Paste iamge set oNmagemanBase = createobject("NmagemanCOM") set oNmagemanSeal = createobject("NmagemanCOM") if oNmagemanBase.Load("sample.jpg") and oNmagemanSeal.Load("sample.t.gif") then oNmagemanBase.Paste oNmagemanSeal oNmagemanBase.Save("sample.out4.jpg") end if

[console output]

ImageDescription : 080417_1614~01 Make : KDDI-KC Model : W52K Orientation : top, left side ResolutionUnit : inches Tag 0xC4A5 : PrintIM XResolution : 72 YCbCrPositioning : Center of pixel array YResolution : 72 -- BrightnessValue : 0 ColorSpace : sRGB ComponentsConfiguration : YCbCr Contrast : Normal CustomRendered : Normal process DateTimeDigitized : 2008:04:17 16:14:29 DateTimeOriginal : 2008:04:17 16:14:29 DigitalZoomRatio : 100/100 ExifVersion : 0220 ExposureMode : Auto exposure ExposureProgram : Program normal ExposureTime : 1/9 sec Flash : Flash did not fire FlashPixVersion : 0100 MeteringMode : Center weighted average PixelXDimension : 240 PixelYDimension : 320 Saturation : Normal SceneCaptureType : Standard Sharpness : Normal WhiteBalance : Auto white balance -- GPSLatitude : 36:4:0.04 GPSLatitudeRef : N GPSLongitude : 136:14:44.56 GPSLongitudeRef : E GPSMapDatum : WGS-84 GPSProcessingMethod : JIS GPSVersionID : 2 2 0 0 --
動作環境
Windows 2000, XP, 2003 Server, Vista, Server 2008, 7 and later
パッケージ内容
NmagemanCOM.dll
NmagemanCOMライブラリ本体
注意事項
  1. 本ソフトウェアの利用は良識の範囲内でお願い致します。
  2. 本ソフトウェアの利用による損害の保証はお受けできません。
  3. 本ソフトウェアの利用は楽しんで行っていただきますようお願い致します。
インストール方法
  1. "NmagemanCOM.dll" をRegsvr32。
リファレンス
[ New Color ] [ Update Color ]
NmagemanCOM Library
NmagemanCOM
Interface
INmagemanCOM
ProgID
NmagemanCOM
NOM Name
NmagemanCOM [default]
EFormat
  • FMT_UNKNOWN = -1
  • FMT_BMP = 0
  • FMT_ICO = 1
  • FMT_JPEG = 2
  • FMT_JNG = 3
  • FMT_KOALA = 4
  • FMT_LBM = 5
  • FMT_IFF = FMT_LBM
  • FMT_MNG = 6
  • FMT_PBM = 7
  • FMT_PBMRAW = 8
  • FMT_PCD = 9
  • FMT_PCX = 10
  • FMT_PGM = 11
  • FMT_PGMRAW = 12
  • FMT_PNG = 13
  • FMT_PPM = 14
  • FMT_PPMRAW = 15
  • FMT_RAS = 16
  • FMT_TARGA = 17
  • FMT_TIFF = 18
  • FMT_WBMP = 19
  • FMT_PSD = 20
  • FMT_CUT = 21
  • FMT_XBM = 22
  • FMT_XPM = 23
  • FMT_DDS = 24
  • FMT_GIF = 25
  • FMT_HDR = 26
  • FMT_FAXG3 = 27
  • FMT_SGI = 28
  • FMT_EXR = 29
  • FMT_J2K = 30
  • FMT_JP2 = 31
EMetadataModel
  • MDM_NODATA = -1
  • MDM_COMMENTS = 0 // single comment or keywords
  • MDM_EXIF_MAIN = 1 // Exif-TIFF metadata
  • MDM_EXIF_EXIF = 2 // Exif-specific metadata
  • MDM_EXIF_GPS = 3 // Exif GPS metadata
  • MDM_EXIF_MAKERNOTE = 4 // Exif maker note metadata
  • MDM_EXIF_INTEROP = 5 // Exif interoperability metadata
  • MDM_IPTC = 6 // IPTC/NAA metadata
  • MDM_XMP = 7 // Abobe XMP metadata
  • MDM_GEOTIFF = 8 // GeoTIFF metadata
  • MDM_ANIMATION = 9 // Animation metadata
  • MDM_CUSTOM = 10 // Used to attach other metadata types to a dib
INmagemanCOM

画像を様々に扱います。

プロパティ
EFormat Format [RW]
画像のフォーマットを取得・設定します。
FormatにはLoad時の値が格納されており、Save時にはこの値が利用されます。
Load時とは別の形式で保存する場合はこの値を変更してからSaveしてください。
long Width [RW]
画像の幅を取得・設定します。
設定した場合は縦横比率固定でリスケール(リサイズ)されます。
long Height [RW]
画像の高さを取得・設定します。
設定した場合は縦横比率固定でリスケール(リサイズ)されます。
Object Metadata(EMetadataModel eModel) [R]
画像のメタデータ(Exif-TIFF,Exif-GPS,etc...)を取得します。
戻り値は Scripting.Dictionary です。
指定したeModelのメタデータが存在しない場合はNothingが返ります。
メソッド
bool Load(Variant* pSource)
pSource
読み込み元画像。
 ○文字列:画像ファイルへのパス
 ○Object:画像を格納したストリームオブジェクト(IStream)
戻り値
成否

画像を読み込みます。
読み込みが完了するとFormatに画像形式が格納されます。

bool Save(Variant* pDest)
pDest
画像保存先。
 ○文字列:保存先ファイルへのパス
 ○Object:保存先のストリームオブジェクト(IStream)
戻り値
成否

画像を保存します。
保存はFormatに指定された形式で行われます。

void Paste(Object oPut, long nX=0, long nY=0)
oPut
貼り付ける画像オブジェクト(NmagemanCOM object)。
PNGやGIFなどの透過画像を渡すこともできます。
nX
貼り付けるX座標。
nY
貼り付けるY座標。
戻り値
[なし]

現在の画像に oPut で渡される画像を貼り付けます。
貼り付ける位置は nX, nY で指定可能です。
座標は現在の画像の左上が(0,0)です。
oPutの透過情報(alpha値)は貼り付け処理時に利用されます。
元画像は強制的に32bit画像に変換されます。

更新履歴
2008/09/10
  • Version: 1.0.0.0
2008/09/16
  • Version: 1.1.0.0
2010/04/02
  • Version: 1.1.1.0
  • x64対応
謝辞

NmagemanCOMの制作にあたり以下のモノを包含させていただきました。
各提供者の方々に厚く御礼申し上げます。

FreeImage
FreeImage Public License
--------------------------------------------------------------------------------
This software uses the FreeImage open source image library. See http://freeimage.sourceforge.net for details.
FreeImage is used under the FIPL, version 1.0.