(Little known fact: Most thumbnails in JPGs are
JPGs, but they can also be BMPs or an obscure 3rd
type. This script can extract the first two.)
"GS" <gs@v.invalid> wrote
..which is working to my liking in that it allows selecting pics in WE and >> lets me configure output sizes. (Resizes 300+ pics in less than 10 seconds) >> Problem is that it makes some larger not smaller, even though there's an
option setting to not do that.
Ah. I thought you wanted to do something like an
Explorer thumbnail view. You could take a look
at this:
https://www.jsware.net/jsware/pprep.php5
I made it mostly for the woman I live with but
also sold it as shareware for a few years. You drop
a file or folder, then you can batch process a whole
folder with resizing and/or cropping. To accommodate
a large audience there are only 3 possible sizes, but
in the settings you can decide what those are. The
cropping was especially aimed at easily creating images
with the right ratio for various printing options, to
fit an 8x10 frame, a 3x5 print, etc.
If it's useful I'm happy to share whatever code you
might want. I think most of it uses some very nice
code from one Peter Scale, who wrote various
image operations in pure VB, including various resizing
methods.
"GS" <gs@v.invalid> wrote
..which is working to my liking in that it allows selecting pics in WE and >> lets me configure output sizes. (Resizes 300+ pics in less than 10 seconds) >> Problem is that it makes some larger not smaller, even though there's an
option setting to not do that.
Ah. I thought you wanted to do something like an
Explorer thumbnail view. You could take a look
at this:
https://www.jsware.net/jsware/pprep.php5
I made it mostly for the woman I live with but
also sold it as shareware for a few years. You drop
a file or folder, then you can batch process a whole
folder with resizing and/or cropping. To accommodate
a large audience there are only 3 possible sizes, but
in the settings you can decide what those are. The
cropping was especially aimed at easily creating images
with the right ratio for various printing options, to
fit an 8x10 frame, a 3x5 print, etc.
If it's useful I'm happy to share whatever code you
might want. I think most of it uses some very nice
code from one Peter Scale, who wrote various
image operations in pure VB, including various resizing
methods.
I maybe should have explained that: One can't
just extract a thumbnail and load it into a
picturebox. A JPG thumbnail is, in fact, an actual
file. But uncompressed RGB thumbnails are in reverse
byte order and have no header. So the bytes have
to be reversed. Then a header has to be created.
Only then do you have a file that can be loaded.
It was Sat, 28 Mar 2020 14:43:48 -0400 when
"Mayayana" <mayayana@invalid.nospam> wrote:
I maybe should have explained that: One can't
just extract a thumbnail and load it into a
picturebox. A JPG thumbnail is, in fact, an actual
file. But uncompressed RGB thumbnails are in reverse
byte order and have no header. So the bytes have
to be reversed. Then a header has to be created.
Only then do you have a file that can be loaded.
My point is that Windows GDI APIs work on DIBs, those
are an in-memory representation of an image which may
then be stored to (or retrieved from) whatever
format, be it JPG, PNG or whatever, such formats are
just STORAGE formats, so instead of focusing on how a
given image is stored, it would be a better idea to
focus on how to quickly render it, then, to retrieve
the image from storage and decode it, there are a
bunch of libraries and APIs, so that shouldn't be a
big issue, nor it would be how the image is stored,
once you load and decode it from storage, you'll have
a DIB and that's all you need to show/manipulate it,
no need to worry about orientation/format/whatever
It was Sat, 28 Mar 2020 14:43:48 -0400 when
"Mayayana" <mayayana@invalid.nospam> wrote:
I maybe should have explained that: One can't
just extract a thumbnail and load it into a
picturebox. A JPG thumbnail is, in fact, an actual
file. But uncompressed RGB thumbnails are in reverse
byte order and have no header. So the bytes have
to be reversed. Then a header has to be created.
Only then do you have a file that can be loaded.
My point is that Windows GDI APIs work on DIBs, those
are an in-memory representation of an image which may
then be stored to (or retrieved from) whatever
format, be it JPG, PNG or whatever, such formats are
just STORAGE formats, so instead of focusing on how a
given image is stored, it would be a better idea to
focus on how to quickly render it, then, to retrieve
the image from storage and decode it, there are a
bunch of libraries and APIs, so that shouldn't be a
big issue, nor it would be how the image is stored,
once you load and decode it from storage, you'll have
a DIB and that's all you need to show/manipulate it,
no need to worry about orientation/format/whatever
The .NET examples I've found seem to do this because when they Save the modified image the format is passed as arg2. Since VB6 doesn't work with the .NET Framework (or does it somehow?) I'm looking to duplicate in VB6!
"GS" <gs@v.invalid> wrote
Found nothing on Peter Scale yet but I'm very interested in the resizingI think this is it:
code you use!
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=46515&lngWId=1
I'll try to pull together my code tomorrow and
post it or post a link.
"GS" <gs@v.invalid> wrote
Need way to do the following:
2. Determine orientation by examine w/h max to get new width;
This will be 480 if portrait, 640 if landscape.
Aspect ratio will auto-set height.
3. Save the pic file by overwriting existing;
Here's my image class:
https://www.jsware.net/Files2/imclass.zip
The code works like this:
Dim oPic As StdPicture
Dim ImOb As cImage, ImOb2 As cImage
Set oPic = LoadPicture(sPathSrc)
If (Err.Number = 0) Then
Set ImOb = New cImage
LRet = ImOb.CopyStdPicture(oPic)
'-------
sPathSrc is the path of the image file. So you
load a BMP/JPG/GIF into a StdPicture and then
copy that into the class. From there all sorts of
operations can be done, including resizing, cropping,
etc. and writing a new imahe to disk as BMP or JPG.
These were the most efficient methods I found.
There's alsodownloaded this earlier...
https://www.jsware.net/Files2/resizetest.zip
That demonstrates that GDI+ resizing is faster than
VB methods using an Image control, with much
better picture quality. It's also slightly better
than WIA in terms of both speed and quality.
For sheer speed with large images I found jpegturbo
was the fastest resizer, by using the closest size
among the 8 (?) presets, then resizing that as needed.
Going from very big down to small is what takes so
much time.
Of course, none of this will handle PNG or TIF.
You'll need external libraries for that. I have code
for rendering PNG in VB, but not for saving as PNG.
And it's slow, anyway.
"GS" <gs@v.invalid> wrote
sPathSrc is the path of the image file. So you
load a BMP/JPG/GIF into a StdPicture and then
copy that into the class. From there all sorts of
operations can be done, including resizing, cropping,
etc. and writing a new imahe to disk as BMP or JPG.
These were the most efficient methods I found.
Looks simple enough but was looking to NOT need an image control. I'll give >> this a try regardless.
Not an image control. A class that provides an
image object to simplify operations. You load the
file into a StdPicture, then copy that to the image
*class*. Then you can resize, crop, write to disk
without further handling details.
"GS" <gs@v.invalid> wrote
Nice! Thanks for clarifying as I know absolutely nothing about working with >> images. (I use a 3rd party utility for making icons after I design them and >> screencapture to transparent GIFs)
If you don't ffigure it out I can provide more sample
code. But it's pretty basic from outside the class.
You create an instance from a StdPicture and then
use the functions of the class object to do whatever
you need. Internally it's as lean as I could get it.
"GS" <gs@v.invalid> wrote in message
Hi All,
I've been searching for ideas on how to manage batch resizing of images in >> a VB6.exe explorer app,
I haven't been all through the thread so this might have already have been suggested -
https://www.mvps.org/emorcillo/en/code/vb6/thumbnail.shtml
I adapted it a long time ago for VBA in Excel to create thumbnails of all images in the supplied folder and show them on a form (in a column in a scrollable frame), click a thumbnail to show the full size image on the same form. For your purposes wouldn't need to show them, as StdPicture objects just 'SavePicture' back to file, obviously with a modified name if to same folder.
Peter T
Hi All,
I've been searching for ideas on how to manage batch resizing of images in
a VB6.exe explorer app,
'--resize an image in proportion to original and paint.
Public Function ResizeAndPaintGDIP(FileName As String, DesthDC As Long,
DestW As Long, Interpolation As Long) As Long
"GS" <gs@v.invalid> wrote
No. DesthDC is destination DC. That's the handle'--resize an image in proportion to original and paint.
Public Function ResizeAndPaintGDIP(FileName As String, DesthDC As Long,
DestW As Long, Interpolation As Long) As Long
Do I assume that DesthDC and DestW are my target sizes? How would I know
this prior to loading the image to find out existing size? (file details,
perhaps?)
for painting, which you don't want. Maybe I can clean this
up, but I was doing it last minute today. (Now that I'm
home all day I don't seem to have a minute to spare!)
It's confusing because I had two functions. One is
opening a file and doing a resized paint to a picturebox.
The other is taking bitmap bits, getting an hBitmap
handle from that, and using the handle to save a JPG
to disk.
So a lot of what you want is here but the middle step,
resizing and ending up with an hBitmap, needs to be
done differently. I'll try to work on it tomorrow.
'--resize an image in proportion to original and paint.| > Public Function ResizeAndPaintGDIP(FileName As String, DesthDC As Long,
"GS" <gs@v.invalid> wrote
I'm working out getting file info via "Shell.Application"; - going well!
That happens to be another area of interest for me.
I might have something useful from my explorer bar code.
"GS" <gs@v.invalid> wrote in message
Hi All,
I've been searching for ideas on how to manage batch resizing of images
in a VB6.exe explorer app,
I haven't been all through the thread so this might have already have
been suggested -
https://www.mvps.org/emorcillo/en/code/vb6/thumbnail.shtml
I adapted it a long time ago for VBA in Excel to create thumbnails of all
images in the supplied folder and show them on a form (in a column in a
scrollable frame), click a thumbnail to show the full size image on the
same form. For your purposes wouldn't need to show them, as StdPicture
objects just 'SavePicture' back to file, obviously with a modified name
if to same folder.
Peter T
Thanks Peter, I'll look at this too. I'll be doing all my testing in
Excel14 anyway since I already have a project going for doing other
related tasks!
"GS" <gs@v.invalid> wrote in message news:r5t735$3bm$1@dont-email.me...
"GS" <gs@v.invalid> wrote in message
Hi All,
I've been searching for ideas on how to manage batch resizing of images >>>> in a VB6.exe explorer app,
I haven't been all through the thread so this might have already have been >>> suggested -
https://www.mvps.org/emorcillo/en/code/vb6/thumbnail.shtml
I adapted it a long time ago for VBA in Excel to create thumbnails of all >>> images in the supplied folder and show them on a form (in a column in a
scrollable frame), click a thumbnail to show the full size image on the
same form. For your purposes wouldn't need to show them, as StdPicture
objects just 'SavePicture' back to file, obviously with a modified name if >>> to same folder.
Peter T
Thanks Peter, I'll look at this too. I'll be doing all my testing in
Excel14 anyway since I already have a project going for doing other related >> tasks!
I should have mentioned, if you just want the job done rather than the fun of doing it yourself, look at www.irfanview.com
File / Batch Conversion/Rename / Advanced / Set long side to # (pixels, cm or inches)
You'll probably want to tick preserve aspect ratio and resample, dozens more options on the advanced page, save with same date/time as the original is a nice touch.
Back on the main page various ways to filter which images to process, and an 'include subfolders' option.
I've been using IrfanView since last century and still find new things it can do, my all time favourite freeware app since ever, bar none! Hmm, I'm well overdue a top-up donation:)
Peter T
"GS" <gs@v.invalid> wrote in message news:r5t735$3bm$1@dont-email.me...
"GS" <gs@v.invalid> wrote in message
Hi All,
I've been searching for ideas on how to manage batch resizing of images >>>> in a VB6.exe explorer app,
I haven't been all through the thread so this might have already have been >>> suggested -
https://www.mvps.org/emorcillo/en/code/vb6/thumbnail.shtml
I adapted it a long time ago for VBA in Excel to create thumbnails of all >>> images in the supplied folder and show them on a form (in a column in a
scrollable frame), click a thumbnail to show the full size image on the
same form. For your purposes wouldn't need to show them, as StdPicture
objects just 'SavePicture' back to file, obviously with a modified name if >>> to same folder.
Peter T
Thanks Peter, I'll look at this too. I'll be doing all my testing in
Excel14 anyway since I already have a project going for doing other related >> tasks!
I should have mentioned, if you just want the job done rather than the fun of doing it yourself, look at www.irfanview.com
File / Batch Conversion/Rename / Advanced / Set long side to # (pixels, cm or inches)
You'll probably want to tick preserve aspect ratio and resample, dozens more options on the advanced page, save with same date/time as the original is a nice touch.
Back on the main page various ways to filter which images to process, and an 'include subfolders' option.
I've been using IrfanView since last century and still find new things it can do, my all time favourite freeware app since ever, bar none! Hmm, I'm well overdue a top-up donation:)
Peter T
"GS" <gs@v.invalid> wrote
Thank you so much for your time&effort; - I appreciate it immensely!
Irfanview seems to be doing a much better job 'all-in-1-app' than anything >> I've tried so far. (800+ files in about 8 seconds)
I'll spend time with your solution (once I've gained some lost ground here) >> so I can have my own custom feature[s].
OK. I'll leave it at that. You probably can't beat
Irfan View. It was nice to refresh my memory a bit,
though. I've got free time lately but haven't had
any interesting coding projects for awhile.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 91:32:23 |
Calls: | 6,658 |
Files: | 12,203 |
Messages: | 5,334,171 |