Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
What is your IM version and platform? Please always provide that infomation.
You say that the size of the file must not change. Yet, your desired result is neither the width or height of your input image. So what exactly are you after? Just the bounding box of the difference area? If so, then try (assuming IM 6 Unix)
Sub convert()
Dim original As String
Dim difference As String
Dim output As String
Dim wh_orig As String
Dim wh_dif As String
Dim IM As String
Dim y As Integer
IM = "C:\Program Files\ImageMagick-7.0.5-Q16\magick.exe"
original = "K:\autosize_wet.png"
difference = "K:\autosize_wet_change.png"
output = "K:\autosize_wet_result.png"
wh_orig = Run_ImageMagick("""" & IM & """ convert """ & original & """ -format ""%G"" info:""")
wh_dif = Run_ImageMagick("""" & IM & """ convert """ & original & """ """ & difference & """ -compose difference -composite -threshold 0 -format ""%@"" info:""")
Run_ImageMagick """" & IM & """ convert """ & difference & """ -crop " & wh_dif & " +repage """ & output & """"
y = InStr(1, wh_dif, "+")
wh_dif = Mid(wh_dif, y, Len(wh_dif) - y + 1)
wh_orig = wh_orig & wh_dif
Run_ImageMagick """" & IM & """ convert """ & output & """ -set page " & wh_orig & " -background transparent -flatten """ & output & """"
End Sub
Public Function Run_ImageMagick(Send As String) As String
Set WshShell = CreateObject("WScript.Shell")
Set WshExec = WshShell.Exec(Send)
Set OutStream = WshExec.StdOut
Dim str As String
While Not OutStream.AtEndOfStream
str = str & Trim(OutStream.ReadLine())
Wend
Run_ImageMagick = str
End Function
Last edited by trexmernii on 2017-04-01T02:44:10-07:00, edited 1 time in total.