Member Avatar for tawes01

I want to make a c++ program that can open an image that is in any of the major formats (jpg, gif, bmp, png) and has any size and I want to resize it to a specific size (no, I don't care if it looks stretched) and save it to a different folder under the same file name. I'm not worried about maintaining the same file format (like, if it's easier to convert it to bmp before working with it, i'm okay with that).

What I'm doing is revamping my website's photo gallery, and I want an easy thumbnail generator where you just drag and drop the original, multi-megabyte file onto a program that instantly creates a thumbnail for you and all you have to do is add that thumbnail to the gallery page.

Is this possible? Does anyone have any snippets or links to tutorials?

By the way, I'm using Dev-C++ on windows 7.

Recommended Answers

All 7 Replies

You want to do something non-trivial.

Why not just use Irfanview?

The OpenCV library can do this easily. It might be a bit of overkill since OpenCV is a lot more feature-rich than you need.

Another alternative and very easy to use library is FreeImage.

Also, if you have access to linux, either on your computer or your website's server machine, you can solve your problem very easily with a simple shell script that calls the "convert" linux-command. For example, these simple commands would work:

$ cp src_dir/*.jpg dest_dir/
$ convert -size 80x80 dest_dir/*.jpg -resize 80x80

I realise this is the C++ forum, however, is there any reason you cannot use .NET?

What you propose is very trivial to achieve in C# and can be accomplished ins approximately 20 lines of code.


As for the C++ version, you're going to need an image library as the previous two posters have mentioned. Either that, or create your own interpolation library so that you can average the colours over a specified area (so if you want a 4-1 reduction, average at 4 pixels at a time into 1 pixel) seems to be a logical step.

Member Avatar for tawes01

What exactly is different from C++ to C#?

The .NET Framework has enough built-in tools for you to manipulate just about any type of image. I'm sure the OpenCV framework is more than enough and the freeimagelibrary would be great, but as you're on Windows 7 there's no reason to have to go to all that effort when the framework will do it for you ;)

(Unless of course you want to learn the complication of it all, then feel free to go nuts in C++ :D )

Why not just use a free tool someone already wrote that does exactly what you want, like Irfanview?

Member Avatar for tawes01

Okay. After looking into an easier way to do this, I found Picture Resize. Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.