Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image resizing utility?
#1
i'm Has anyone done batch resizing of images in QB64? 
I'm looking to make a simple drag and drop exe that you drag one or more pictures onto (or maybe send it a command line parameter with a path, or a path + a pattern) and it will auto-convert all the images in the folder to some predetermined target resolution at a high quality (or maybe be able to choose the quality vs processing time?) and write the converted images to target folder (or the same folder but with some prefix or change to the file name so you can easily separate them). It would support JPEG / PNG maybe also BMP / GIF, maybe specify the output format + quality? 
Bonus if the created file retains the modified date of the original. 

If anyone has done or seen this kind of thing, I would be interested in any samples or advice...!

UPDATE: I think ImageMagick is what I was thinking of. 
It would still be interesting to do this in QB64, but ImageMagick with a batch file should work for now...

https://www.imagemagick.org/script/download.php#windows

imagemagick - Lightweight command-line image resizer? - Stack Overflow

https://stackoverflow.com/questions/3455...ge-resizer
Reply
#2
Everything you want to do can be done easily with the SaveImage library.

Basic pseudocode for the routine would be the following:

'$INCLUDE:'SaveImage.BI'

DO
'LoadImage file that you want to resize/reformat
'NewImage a screen to the size that you want the file to be saved as
'_PutImage ,loadimageHandle, newimageHandle to put and scale the original image onto the new image
'x = SaveFullImage("exportFileName.EXT", newimageHandle)
'Free Unused Images
LOOP UNTIL finished with all the files you want to change

'$INCLUDE:'SaveImage.BM'


And that's basically it!

Just change the SaveFullImage extension to the extension that you want to save your file as: BMP, GIF, JPG, or PNG -- the routine will do all four export types, based upon what extension you specify with the filename.

Change the NewImage(x, y, 32) x and y size to the size that you want to resize to.

https://qb64phoenix.com/forum/showthread.php?tid=20 <-- SaveImage library is here.
Reply
#3
(07-19-2022, 05:49 PM)SMcNeill Wrote: Everything you want to do can be done easily with the SaveImage library.

Basic pseudocode for the routine would be the following:

'$INCLUDE:'SaveImage.BI'

DO
    'LoadImage file that you want to resize/reformat
    'NewImage a screen to the size that you want the file to be saved as
    '_PutImage ,loadimageHandle, newimageHandle to put and scale the original image onto the new image
    'x = SaveFullImage("exportFileName.EXT", newimageHandle)
    'Free Unused Images
LOOP UNTIL finished with all the files you want to change

'$INCLUDE:'SaveImage.BM'


And that's basically it!

Just change the SaveFullImage extension to the extension that you want to save your file as:  BMP, GIF, JPG, or PNG -- the routine will do all four export types, based upon what extension you specify with the filename.

Change the NewImage(x, y, 32) x and y size to the size that you want to resize to.

https://qb64phoenix.com/forum/showthread.php?tid=20 <-- SaveImage library is here.

This is awesome, thank you.
Reply
#4
(07-19-2022, 05:49 PM)SMcNeill Wrote: Everything you want to do can be done easily with the SaveImage library.
:
    'x = SaveFullImage("exportFileName.EXT", newimageHandle)
:
Somebody just said, "GOTCHA!" <---
Not the "SaveImage" that is still somewhere in Wiki.
Thank you. I learned something new today.
Reply




Users browsing this thread: 1 Guest(s)