SketchUp and ImageMagick


#1

hello developers,

I want to use ImageMagick for a future extension and I don’t know what is the proper way to have ImageMagick installed in users computer.

Here is an example of how I’ll be calling ImageMagick command from SketchUp using Ruby…

`cd C://Users//Name//Desktop//folder && magick 1.jpg 2.png`

The above code works great but how to ensure the user has ImageMagick installed?
Do I just give them Step by Step instructions?
Or is there is a better way?

Thanks in advance!


#2

have a look at the new Material Resizer as it ships bundled with ImageMagick…

john


#3

This seems to be the solution I was looking for…Thank you very much!

I am still not sure exactly how they are making it work but I’ll dig in the code to figure it out. If I run to further questions I’ll post them here.


#4

Do not change the user’s working directory for any more time than it takes to do your “thing”.

From Ruby it is best to use the block form of the Dir::chdir() method as it restores the previous working directory when the block ends.

Dir.chdir( File.join(ENV["USERPROFILE"],"/Desktop/folder") ) do
  `magick 1.jpg 2.png`
end

One issue with “special folders” on Windows is they may not be named “Desktop”.
Ie, the directory names may be localized. You can use the WIndows scripting Host object in Ruby via WIN32OLE class to get the folder strings.

require 'win32ole'

def get_desktop_foldername
  WIN32OLE.new("WScript.Shell").SpecialFolders("Desktop")
end

REF:

https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/9x9e7edx(v%3Dvs.84)


#5

Thank you!