Solved

Using ImageMagick to create a thumbnail, through VB6

Posted on 2013-05-16
15
703 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
Comment Utility
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
Comment Utility
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
Comment Utility
That sounds right or I think you can leave quality blank but setting it to 100 sounds like a good idea.
0
 

Author Comment

by:hrolsons
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I've requested that this question be deleted for the following reason:

unsolved
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 52

Expert Comment

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

Author Comment

by:hrolsons
Comment Utility
Oh, you're totally right.  Silly me!!!
0
 

Author Comment

by:hrolsons
Comment Utility
Still working on it.
0
 

Author Comment

by:hrolsons
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you for the points!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

772 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

12 Experts available now in Live!

Get 1:1 Help Now