Solved

Using ImageMagick to create a thumbnail, through VB6

Posted on 2013-05-16
15
716 Views
Last Modified: 2013-06-08
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
Comment
Question by:hrolsons
  • 8
  • 7
15 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39172576
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
 

Author Comment

by:hrolsons
ID: 39172658
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39172877
That sounds right or I think you can leave quality blank but setting it to 100 sounds like a good idea.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:hrolsons
ID: 39172963
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39172980
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
 

Author Comment

by:hrolsons
ID: 39173017
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
 

Author Comment

by:hrolsons
ID: 39231791
I've requested that this question be deleted for the following reason:

unsolved
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39223892
Ok, your last comment was you would look at it. I never  heard back.  Good luck.
0
 

Author Comment

by:hrolsons
ID: 39223936
Oh, you're totally right.  Silly me!!!
0
 

Author Comment

by:hrolsons
ID: 39223938
Still working on it.
0
 

Author Comment

by:hrolsons
ID: 39223949
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39224443
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
 

Author Comment

by:hrolsons
ID: 39229922
I ended up using http://www.rw-designer.com/picture-resize for the thumbs.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39230956
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39231803
Thank you for the points!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction In a previous article (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_6537-PaperPort-Upgrade-How-to-download-and-install-updated-versions-of-PaperPort-11-and-12.html) (now deprecated), I discussed how to upgrad…
In a previously published article (http://www.experts-exchange.com/articles/10331/Automatic-Duplex-Scanning-in-PaperPort-Versions-11-12-14.html) here at Experts Exchange, I explained how to achieve duplex (double-sided) scanning in Nuance's PaperPor…
Users will learn how resize a batch of photos from a single command in Photoshop via Photoshop's Image Processor. Open up an Image you'd like to resize in Adobe Photoshop: Adjust the image size according to your preferences. Image > Adjustments > …
The goal of the tutorial is to teach the user what exposure is and how to use the exposure slider. Analyze the photo that you want to edit, then adjust the exposure slider to your liking.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now