Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Using ImageMagick to create a thumbnail, through VB6

Posted on 2013-05-16
15
718 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article provides the solution to a question (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28674207.html) posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
In a previous article here at Experts Exchange (http://www.experts-exchange.com/articles/18414/Create-a-PDF-file-with-Contact-Sheets-montage-of-thumbnails-for-all-JPG-files-in-a-folder-and-each-of-its-subfolders-using-an-automated-batch-method.html)…
The goal of the tutorial is to teach the user how to import photos into Adobe Lightroom efficiently and to keep everything organized.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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