I have a Xojo web app with pictures. When a user is uploading a .png - picture bigger than 500x500, I want to change the image to 500x500. I don’t want to cut the image, so it should scale down, and make transparent background bevels, if nessassary.
I have the MBS Plugins ImageMagick [because I have the Complete version], but I don’t find the correct commands in Xojo to do it.
I found this site for a similar php plugin with imagemagick. in this documentation the cl - logo mode is exactly what I’m searching for in MBS Plugin:
“This mode creates image of exact width and height given. Original image is resized to fit into the boundaries. If source image is PNG additional image areas will be transparent.”
So, I think it is possible with Xojo. But I don’t find the commands. Does anyone of you using ImageMagick with the MBS Plugin and know the right command?
Apart from the transparency you dont need ImageMagick for this.
1/Create a picture of the exact size you want
2/ Get the maximum of width or height of the original
3/ draw the original onto the picture, centred, using the ratio of the original to the new to resize.
[code]
dim newpic as new picture (siz,siz) // or with the ,32) ending
dim maxsiz as double = original.height
if original.width > original.height then maxsiz = original.width
//you want it centred, so you need to adjust the left and top too
newpic.graphics.drawpicture
original,
(siz -(original.width * siz/maxsiz) ) /2 ,
( siz - (original.height * siz/maxsiz) )/2 ,
original.width * siz/maxsiz ,
original.height * siz/maxsiz,
0, 0,
original.width,original.height[/code]
Code is untested and illustrative only
I would not use my plugin for simply cutting picture…
GraphicsMagick plugin is great for advanced effects, scaling or 16 bit depth.