Working with photographs

I discovered xojo a few weeks ago and love it.
Could someone point me to documentation or examples to do with working with images.
I"m talking loading a picture, resizing it, adding an overlay or watermark, and more stuff like that.
At the moment I use imagemagick but it is overkill for simpler operations.

Thanks,
Christian

1 Like

Hello @Christian_Titeca and welcome to Xojo and the Forums :grinning:

You can check out the Xojo programming eBook https://www.xojo.com/resources/learn.php

Xojo YouTube Channel is a great recourse https://www.youtube.com/@XojoInc

There are example projects you can study (and use) , just launch Xojo → Click on Examples → find an example that meets your needs

1 Like

The documentation for Picture will tell you about image input and output:
https://documentation.xojo.com/api/graphics/picture.html

The documentation for Graphics will tell you about manipulating the image to do things like resizing and adding overlays:
https://documentation.xojo.com/api/graphics/graphics.html

Word of caution.

Xojo’s image loading capabilities are really designed for getting images into the user interface and not really for image processing.

If this is for more than just a learning exercise / hobby project then you will more than likely need the MBS and / or the Einhuger plugins.

2 Likes

you can get the graphics context from a picture
.Graphics

something like

var g as Graphics = pic.Graphics
g.DrawPicture

with DrawPicture you can draw a scaled picture

adding an overlay or watermark

have a look at the .Draw Methods from Graphics

use a color with alpha (transparent) to draw a watermark

1 Like

That is what I tought, in line with my experience of visual basic 6.
Okay I"ll try to find these plugins.

Thank you,
Christian

Einhugur and MBS Plugins may be of great value in this case (as so often) :wink:

Those plugins do not offer anything over imagemagick which is what I use now.
I was looking to simplify things.
But thanks to everyone replying.

What’s the command to start a commandline application with parameters and retrieve the result in a variable?

Thank you,
Christian

Shell

Yes, thank you.

Have a great day!

1 Like

I have had bad experiences getting large amounts of data back from the shell. The plugins work much better with Xojo. There is also a project with dylib for OpenVC which is much faster.

The ImageMagick command line tools usually work with files so the amount of data received by the shell would be small.

1 Like

Could you elaborate a little bit on dylib for Open VC or point me to the download page/tutorials?

Christian

Please contact https://forum.xojo.com/u/Marius_Dieter_Noetzel .

One should not underestimate Xojo’s capabilities though. I do quite a lot of high end image processing on very large files with my app, and it works very well for me. The mentioned plug-ins do of course help too though.

1 Like

Would you care showing me a few lines of code?

I guess it depends on what you are doing. However, there are some fundamental issues that make image processing difficult if you are using the Picture class. These include, quirks in the ICC colour management handling and the fact that they use premultiplied alpha.

Hi Christian,

What I do is highly specialized, so probably not a good starting point for you.

In short, I import a 3D model of a sail, generate an optimized cutting layout with seam allowances and cutting data, import a very high resolution image and apply it to the 3D shape using advanced UV-mapping, and generate a ready to cut and in-scale image (in reality several images) that matches the vector cut lines precisely including bleed.

The overview in the middle is about 350 megapixels.

The rendering to the right is a 3D presentation of the result as rendered in a high end rendering app. The 3D model as a hole comes from my app though, including all texture mapping, as my app simply does a better job that the rendering app does.

Sorry if this was not very useful for you. Probably more like confusing really. What I do is of course a bit weird….

Claes

2 Likes

Thank you :slight_smile:
It does help in the sense that it shows the sky is the limit :wink:
Christian

What I’m doing is:
check folder for incoming photographs
convert to jpg if necessary
resize/crop
add overlay image (which is a frame)
add logo
add qrcode to find the picture online.

All this i do already using imagemagick commandline within a script.
It works well but I wanted to create a bit of a more elegant solution.

So, no urgency here, just trying to gauge whether I can do this in xojo.

Christian