Thread: Directory & Image program..

  1. #1
    the Wizard
    Join Date
    Aug 2004
    Posts
    109

    Directory & Image program..

    Hi folks,

    I have a lot of pictures (600+), and have to change the dimentions of them, from 1024*768 to 800*600, but I'm having some problems, and need some advise and/or help

    A console program is just fine, so I want it to check the folder the program is in, and then check for files with the extension .jpg/.bmp and then change the dimensions..

    I've considered the header file dir.h and it's functions(not use the header file of course ), BUT Microsoft Visual C++ 6 doesn't have the header file, is it possible to grab it from another compiler or does somebody have a better idea, to check the folder for files?? And if your suggesting dir.h and if your want, I would be happy if you would show me a little example.. I'm not that good at C++ yet

    And on to my last problem, how do I change the image dimentions, I haven't found anything on changing that, so if would like some feedback on that to, if anybody knows how

    All kind of help is appreciated very much

    -//Marc Poulsen -//MipZhaP

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    60
    I don't think you can change the images resolution because I have been told that you can't even OPEN images in C++. Someone might suggest ios::bin, F-I/O but I think this would have to be done in windows.h.
    Child who knows C++
    Using Borland C/C++ Compiler 5.5 (Command Line Version)

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    On other solutions to the problem
    http://www.google.com/search?q=image+resizer

    On downloading other compiler's headers
    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    On traversing directories
    http://faq.cprogramming.com/cgi-bin/...&id=1044780608
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    I like Advanced Batch Converter for stuff like this. I once had to convert 770 png's to bmp's. This utility saved a ton of time.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  5. #5
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I use this script for image resizing:
    Code:
    Const MAX_WIDTH  = 800
    Const MAX_HEIGHT = 600
    
    Set ImgIn = CreateObject("WIA.ImageFile")
    Set IP    = CreateObject("WIA.ImageProcess")
    Set FSO   = CreateObject("Scripting.FileSystemObject")
    
    IP.Filters.Add IP.FilterInfos("Scale").FilterID
    IP.Filters(1).Properties("MaximumWidth").Value = MAX_WIDTH
    IP.Filters(1).Properties("MaximumHeight").Value = MAX_HEIGHT
    IP.Filters(1).Properties("PreserveAspectRatio").Value = True
    
    For i = 0 To (WScript.Arguments.Count - 1)
    
    	ImgIn.LoadFile WScript.Arguments(i)
    
    	If (ImgIn.Width > MAX_WIDTH Or ImgIn.Height > MAX_HEIGHT) Then
    		IP.Apply(ImgIn).SaveFile FSO.GetParentFolderName(WScript.Arguments(i)) & "\" & _
    	             "resize_" & FSO.GetFileName(WScript.Arguments(i))
    	Else
    		ImgIn.SaveFile FSO.GetParentFolderName(WScript.Arguments(i)) & "\" & _
    	             "resize_" & FSO.GetFileName(WScript.Arguments(i))
    	End If
    Next
    You'll need Windows XP and the free Windows® Image Acquisition Automation Library.
    Save as a text file with .vbs as the file extension.
    Drag desired files onto it.
    It will handle BMP, JPEG, TIFF, GIF and PNG.

    For use of WIA in C++, see this WIA sample.
    Last edited by anonytmouse; 08-14-2004 at 09:30 PM.

  6. #6
    the Wizard
    Join Date
    Aug 2004
    Posts
    109
    Thx, I'll take a look of what you've posted

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. which data type in image program?
    By TriKri in forum C++ Programming
    Replies: 13
    Last Post: 06-14-2008, 04:17 PM
  3. Replies: 9
    Last Post: 03-03-2006, 10:11 PM
  4. Replies: 4
    Last Post: 03-02-2003, 09:12 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM