[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 748
  • Last Modified:

Using ImageMagick to create a thumbnail, through VB6

I use the following command to successfully convert a .tif file to a .jpg file:

ShellAndWait "C:\Program Files\ImageMagick-6.7.2-Q16\Convert.exe logo.tif logo.jpg", , 60

Does anyone know how I could do something similar to create a thumbnail with the longest side being 150px?
0
hrolsons
Asked:
hrolsons
  • 8
  • 7
1 Solution
 
Scott Fell, EE MVEDeveloperCommented:
I use imagemagick as a com object for classic asp.  Can you see how to covert what I did for your vb6?

http://www.imagemagick.org/Usage/resize/

This is the code I use to resize to a width of 500 and 200 for web which is why the quality is set to 50.  The last line creates a thumb that zooms in a little and centers the image as it zooms.
The greater then sign means only make it smaller and not larger. http://www.imagemagick.org/Usage/resize/#shrink

Set Img = Server.CreateObject("ImageMagickObject.MagickImage.1") 
sourcefolder="c:\somefolder"
thepic=' uploaded image
savefolder_med="c:\another_folder"
savefolder_small="c:\another_folder"

img.Convert sourcefolder&thepic,"-quality","50","-resize","500>",  savefolder_med&thepic
img.Convert sourcefolder&thepic,"-quality","50","-resize","200>",  savefolder_small&thepic
img.Convert "-define", "jpeg:size", "200x200", sourcefolder&thepic,"-thumbnail", "100x100^", "-gravity", "center", "-extent", "100x100" , savefolder_thumb &"thumb"&thepic

Open in new window

0
 
hrolsonsAuthor Commented:
So in my command line above, does the 60 represent quality.  I want the best quality, which would be 100 I assume.  It looks like I need to add to the command line: "-resize","150"
0
 
Scott Fell, EE MVEDeveloperCommented:
That sounds right or I think you can leave quality blank but setting it to 100 sounds like a good idea.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hrolsonsAuthor Commented:
I'm not sure where the 60 came from, because I would never have done 60% quality.  That was a few years ago so I can't remember now.
0
 
Scott Fell, EE MVEDeveloperCommented:
I don't know about the command line since I don't use it but it looks like the info is here http://www.imagemagick.org/script/convert.php 

If you leave it off, I would think the default is 100%
0
 
hrolsonsAuthor Commented:
I looked at ShellAndWait:

Public Sub ShellAndWait(ByVal program_name As String, _
                         Optional ByVal window_style As VbAppWinStyle = vbNormalFocus, _
                         Optional ByVal max_wait_seconds As Long = 0)

So the 60 was simply "max_wait_seconds".  OK, back on topic.  I'll see if I can get "-resize","150"  to work after my son's baseball game tonight.
0
 
hrolsonsAuthor Commented:
I've requested that this question be deleted for the following reason:

unsolved
0
 
Scott Fell, EE MVEDeveloperCommented:
Ok, your last comment was you would look at it. I never  heard back.  Good luck.
0
 
hrolsonsAuthor Commented:
Oh, you're totally right.  Silly me!!!
0
 
hrolsonsAuthor Commented:
Still working on it.
0
 
hrolsonsAuthor Commented:
I'm afraid "-resize" is going to resize the original.  I need to keep the original.  Perhaps I'll copy the original and then resize the copy.
0
 
Scott Fell, EE MVEDeveloperCommented:
Your objectives are

convert a .tif file to a .jpg file
create a thumbnail with the longest side being 150px

It sounds like you want something different.  Look at my original sample.  The first two lines resize.  Using the > sign means only resize if larger.    If your image is 100 and you use resize 150 then the image grows and it should not.  If you use resize 150> the image does not size because 100 is less then 150.    

If you meant to keep the the size as is and just zoom some place or crop.  Look at the third line
0
 
hrolsonsAuthor Commented:
I ended up using http://www.rw-designer.com/picture-resize for the thumbs.
0
 
Scott Fell, EE MVEDeveloperCommented:
It would have helped a great deal to know if you were  looking for something one off or to bake into another program as that is the primary use of ImageMagick.
0
 
Scott Fell, EE MVEDeveloperCommented:
Thank you for the points!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now