Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a folder with some images.

The image names are serial (AD10001 - AD10010).

The images are currently different sizes, (ie a 500x500, a 280x280 etc)

I need 6 copies of each image, each one named in the format :
AD10001-100x100
AD10001-228x228
AD10001-40x40
AD10001-500x500
AD10001-74x74
AD10001-80x80
Ad10002-100x100
and so on

I also need them to be the relevant sizes, ie 40x40 etc.

I have absolutely no idea how to do this.

Can anyone help?

(PS there are not 10 original images, but 26,000!)
Posted
Comments
Sergey Alexandrovich Kryukov 15-Aug-13 12:31pm    
Please, language, platform, application type, and whatever else is relevant...
Is it a Web application, and, if it is, did you think about resampling the images on the fly?
Or, if you need it just once (or on occasional basis), could you just use a ready-to-use utility, which would be the simplest thing, through some batch script?
—SA
Dalek Dave 15-Aug-13 16:30pm    
Sergey, sorry.
VB.Net would be best, or at least some script like php.
What I need is to take images copied manually from the web and stored in a local folder.
I then need to upload the whole folder to a webspace attached to a webstore.
When I upload the products using a CSV file I want to include the path to the folder.
This seems easy: I have named each of the images after the product code of the item, so I can have a set path and just concatenate in the name of the image.
Or so I thought!
The store uses several instances of the same image in different sizes.
When you upload an image manually it does all this for you, but with 30,000 products this would take months to manually input.
So I need a way for "FOR EACH image IN folder, ..." and it needs to have 6 versions, each with a suffix appended to a common name, and each of them to be set to different sizes.
Well beyond the capabilities of a mere accountant with limited programming skills.

How is your batch file skills?

Download the following : http://www.imagemagick.org/script/mogrify.php[^]

Some more help here : http://www.ibm.com/developerworks/library/l-graf/?ca=dnt-428[^]
 
Share this answer
 
Comments
Dalek Dave 15-Aug-13 17:09pm    
Thanks Mehdi.
I recently answered how to resize a bitmap using .NET. All I would to add just for you: do it in cycle and save all those files under the names of you choice. Please see this answer:
resize image in vb.net[^].

This is all really simple and can give you reasonable performance.

The second options is using the ready-to-use utility (and probably enjoying the boost in performance). I would strongly recommend FFmpeg or libavcodec utility. Please see:
http://en.wikipedia.org/wiki/Ffmpeg[^],
http://ffmpeg.org/[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://libav.org/[^].

In both cases, you can get free open-source utilities which can make nearly everything. (And this is much better than ImageMagic which also I tried before, even though it would work for your, too. With ffMpeg, I used to solve most tricky problems when the solution was really hard to find.)

Now, even if you want to run it all through .NET application (even ASP.NET), you can simply run it as a separate process using System.Diagnostics.Process.Start. You can redirect the StandardOutput and StandardError, to capture output or to simply hide it. You will find more than enough examples in the documentation of this class. The file name for the start of process does not have to be the utility. It could also be a batch file starting the utility with different parameters. However, with thousands of images you have I would do it directly in code, not batch file, as you may need to calculate file names and a lot more.

There is another, more complex option: you can find a .NET wrapper library of the ffMPeg or LibAV library and use it immediately in your .NET application, but this would take more labor.

Anyway, if you need some more information, please ask your follow-up questions. I often do massing image and other media processing and know a big deal of it.

Good luck,
—SA
 
Share this answer
 
v2
Comments
Dalek Dave 15-Aug-13 17:10pm    
What can I say?
What a great answer and so many things to poke around at over the weekend.
I will see how I get on, and if I run into any serious trouble I will contact you for some directions.

Thanks very much.
Sergey Alexandrovich Kryukov 15-Aug-13 17:13pm    
You are very welcome, and your next questions, too.
Good luck, call again.
—SA
Richard C Bishop 15-Aug-13 17:11pm    
Wow, you never fail to blow my mind with your knowledge. How long have you been programming if you don't mind my asking?
Sergey Alexandrovich Kryukov 15-Aug-13 17:16pm    
Thank you very much for your nice words.
Programming is not my only and not my first field of work. Even now, it's only a (big) part of my work. And things like ffMpeg use are much closer to my personal hobby activities than work.
"How long" really depends on how to count, but if you are curious, you can easily find out from my Web site you can find at my profile page...
—SA
Richard C Bishop 15-Aug-13 17:19pm    
Thank you, I will check out your page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900