Forums > Jitter

import PNG and read in resolution

Mar 29 2010 | 4:34 pm


I’m importing a PNG, processing it, and then exporting the result.

At the moment I’m reading the image into and then passing it to jit.matrix, but I’m having to explicitly tell the two objects the resolution of the images (650 by 450) as arguments.

Since the images I need to process may not always have these dimensions, I need to able to read the resolution of the image which is being imported and set the and jit.matrix accordingly. Any ideas?

I’m an experienced user of Max/MSP, but this is my first go at Jitter so sorry if it’s a simple question.

Thanks in advance,

Mar 29 2010 | 4:38 pm

make sure is set to @adapt 1, which tells it to adapt to the files original dim.
then put these objects after your… it will analyse the dim of your matrix.

[jit.matrixinfo] -> [route dim] -> and maybe [zl change] if you want to filter out repeats

Mar 30 2010 | 9:44 am

Thanks justin, that works fine.

Mar 30 2010 | 1:52 pm

A new problem: once I’ve exported my processed images, if i try to move/delete them in windows with the max patch still running then I’m told that the they are in use and cannot be deleted.

I’ve tried clearing all of the and jit.matrix objects once processing had finished but this doesn’t seem to work. Any ideas?

If you’re wondering why I care about deleting the files with the patch running, it’s because…
my patch is designed to process a batch of a hundred or so files when it is triggered from a Visual Basic script. The script places a batch of images into the right folder, triggers the max patch to process them and then needs to be able to extract the processed images from the folder and replace them with more raw images, all with the patch still running so that VB can trigger it to process the next batch.

Thanks again,

PS: Also, the file size of the exported PNGs are significantly smaller than the original PNGs (from 12KB to 7KB). Any idea why this might be happening?

Mar 30 2010 | 3:16 pm

dunno about the move / deleting problem, that sounds like it could be platform specific… and i’m on osx so cant help with that one… altho u may get more answers if you posted a copy of the patch, or a patch which illustrates the problem. u should also explain how you are moving / deleting the files? is it manual through windows explorer, or is it thru a script?

the PNG file size issue could be because of a change of bit depth in the colour range < ?> it’s a bit of a shot in the dark, but i would start with checking the files in something like photoshop… then check the file info.


Mar 30 2010 | 4:21 pm

Thanks for replying again. I’m on OSX at home so i’ll try it out when I’m back from work tonight see if it’s any different.

It won’t let me move the files manually. I will be moving the files from a VB script, but that’s not working yet, and since I can’t move the files manually either I’m guessing that’s why the script isn’t working.

Here’s a one-image-at-a-time version of the patch. It’s a bit messy because I had to squeeze in bits from sub-patches into one patch. You’ll also need the javascript script which I’ve attached below (it just removes the .png from the write file path, because jit.matrix puts a .png on the end automatically). I think you’ll have to save the patch, and put the javascript file in the same folder so that the js object can see it.


-- Pasted Max Patch, click to expand. --

  1. remove_ext.js
Mar 30 2010 | 9:39 pm

dont have to much time to look into it at the moment, maybe i’ll have more time tomorrow…
but, had a quick look and 4 things come to mind…

1. u probably need to "clear, bang" to reset all ur matrices (bang actually forces it to clear)
2. u could try "dispose" msg to, to remove it from memory if you want to move it (that might get rid of the in use msg in windows)
3. u could also try "kill" msg to, to permanently delete ur file with no warning dialog : )
4. dont quite get why ur using javascript to remove the extension… [zl ecils 4] is probably easier

sorry its a bit brief, but hope its useful.


Mar 30 2010 | 9:44 pm

-- Pasted Max Patch, click to expand. --

Mar 31 2010 | 8:37 am

‘Dispose’ was exactly what I wanted and works great, thanks.

As for the javascript, thought it would be quicker for me to knock that up than to try to work out how to get |zl ecils| to split a symbol rather than a list.

Thanks again

Mar 31 2010 | 9:41 am

use [fromsymbol] to remove quotes from symbol and convert to list, then use [zl ecils 4]… nice and easy, and that’s one less dependency to worry about!

the problem is sometimes the os doesnt always append the extension, so i guess you need to be careful… or there might be a safer way< ?>


Viewing 10 posts - 1 through 10 (of 10 total)

Forums > Jitter