Dealing with huge images

Opening images can be a problem.
In my windows 32bit app, if it is fed a huge image and I add a mask, it crashes out of memory even wrapped in a try…catch
When it doesnt crash, it’s still pretty sluggish… probably paging to disk.

I can find the dimensions in advance using GMImageMBS and .ping
I could tell my users ‘use a smaller picture’ (they dont need this kind of resolution)

Whats the best way of getting a smaller image from the larger, if I know in advance the source is huge?

GMImageMBS should be able to scale large images for you.

It would also be possible to do this using other MBS plugins via the following:
1.Create a memory mapped picture using PictureMBS
2.Load the image row by row into the memory mapped picture via JPEGImporterMBS
3.Scale the image into a smaller PictureMBS
4.Copy the scaled PictureMBS into a Xojo picture

I’m sure MBS has examples that would help you.

Can you move to a 64 bit app? Much better memory management is one of the big improvements of 64 bit apps.

In a 32 bit window app you can’t even get the the whole 4GB of address space, it’s closer to 2GB Max before bad things start happening.

Doing that in the new year.
(It’s taken me about 7 years to beat the 64 bit version into shape.)

In 64bit, it doesn’t crash, but you can still almost make tea while it loads into the GMImageMBS.

How huge are your images?

I have a 64 bit xojo windows Exe which can handle pretty large images (4k, 8k, and I’ve even tried it with a 10000x10000 image) and performance is OK. I am using MBS but don’t think I’m using GMImageMBS so perhaps that’s important?

‘OK’ is relative of course.
The issue has arisen from a customer using an image that is 12500 x 12500 pixels.
Crashes 32bit Windows - so what I wanted to do is find a way to load it without crashing, shrink it, and discard the big one.
I’ve added a message to say in effect ‘you only need something thats maybe 500 pixels, where did you get this monster?’ for the 32 bit build to keep me going.

64bit will open it. Performance? The open line of code takes about 2 seconds. Not life and death, but unusual. Then reducing size takes about the same, after which we zip along.
I only really started to use GMImageMBS in order to handle orientation.

On Mac, images that were taken with the camera rotated came in correctly.
On Windows, the exif data that tells us which way up the image goes was being ignored, so that photo of the leaning tower of Pisa shows its final fate… ======>
GM has an autoorient method that corrects this.