Image cropping

D

danish.jaypee

Guest
I have this image of a coin that I need to use as an icon in game but while using it as a sprite, the entire square gets imported and I can't find an option of cropping it as a round image so I could only use the coin. I also have another similar image with transparent background that I thought could work but nope, I can't get the sprite to only have coin and nothing else. Is there a way to do this in GMS2 or would I have to use a third-party application to crop out just the coin and then use it as sprite?Screen Shot 2020-08-26 at 5.59.20 PM.png
 

Alice

Darts addict
Forum Staff
Moderator
I guess you could use GM:S editor to remove the background around the coin, but it'll likely be a menial and painful task. You'd need to enter the image editor and use eraser tool for that.
Other graphics editors might be better at removing the background around the object, but I can't know of any editor I could recommend for that.
I wonder about the image with transparent background you mentioned - if it's a simple PNG image, then it should be imported to GM:S just fine without any white background. If there's a problem, I'd sooner suspect an image editor like Paint, which doesn't handle transparency and removes transparency from saved PNGs.

Generally, if you import images made with external editor into GameMaker, your best bet is to have them prepared beforehand so that they're good to use in the game; this includes having correct transparency, too.

If you have the image editor source file (rather than exported bitmap), then maybe there's a way to export the image without the background from editor itself? E.g. in Inkscape I could manipulate the visibility of background and foreground layers and export only the layers I need.

If this bitmap is all you have, then you'll need to get your hands dirty and remove the background yourself - whether in GM:S built-in editor or in some other tool.
Once you do have an image with transparency, you can use Image >> Auto Trim All Frames from GM:S sprite editor to remove the transparent framing around the image (it's a little more complex with multi-image sprite).

If you collaborate with an artist, ask them to export the image without the background, just the transparency around the coin. I'm pretty sure any video game artist worth their salt would setup their image in a way that the background can be easily removed, leaving only the transparent area around the main object.
 
Well, you could do it in GMS using the gpu_set_blendmode_ext commands or else making a custom shader. But both those situations are a lot more complicated than simply cutting the image out in an actual image editor.
 

woods

Member
1598455958567.png

used gms 1.4 sprite editor..
remove color -white- took a few passes at it then manually used eraser and cleaned up leftover pixels around the edge of the coin

quick and dirty...(under 5mins) but it isnt that hard ;o)
 
D

danish.jaypee

Guest
I guess you could use GM:S editor to remove the background around the coin, but it'll likely be a menial and painful task. You'd need to enter the image editor and use eraser tool for that.
Other graphics editors might be better at removing the background around the object, but I can't know of any editor I could recommend for that.
I wonder about the image with transparent background you mentioned - if it's a simple PNG image, then it should be imported to GM:S just fine without any white background. If there's a problem, I'd sooner suspect an image editor like Paint, which doesn't handle transparency and removes transparency from saved PNGs.

Generally, if you import images made with external editor into GameMaker, your best bet is to have them prepared beforehand so that they're good to use in the game; this includes having correct transparency, too.

If you have the image editor source file (rather than exported bitmap), then maybe there's a way to export the image without the background from editor itself? E.g. in Inkscape I could manipulate the visibility of background and foreground layers and export only the layers I need.

If this bitmap is all you have, then you'll need to get your hands dirty and remove the background yourself - whether in GM:S built-in editor or in some other tool.
Once you do have an image with transparency, you can use Image >> Auto Trim All Frames from GM:S sprite editor to remove the transparent framing around the image (it's a little more complex with multi-image sprite).

If you collaborate with an artist, ask them to export the image without the background, just the transparency around the coin. I'm pretty sure any video game artist worth their salt would setup their image in a way that the background can be easily removed, leaving only the transparent area around the main object.

Really appreciate your help! Yeah I do have images with transparent background but looks like I exported them in JPEG format from Shutterstock, so perhaps the import to GMS didn't really make it look like an image with a transparent background. I used the PNG version and it's looking pretty. Thanks for your help!
 
D

danish.jaypee

Guest
View attachment 33691

used gms 1.4 sprite editor..
remove color -white- took a few passes at it then manually used eraser and cleaned up leftover pixels around the edge of the coin

quick and dirty...(under 5mins) but it isnt that hard ;o)
That looks good, bud! I'll keep it in mind when using images that don't have transparent background. Appreciate it!
 

Alice

Darts addict
Forum Staff
Moderator
Really appreciate your help! Yeah I do have images with transparent background but looks like I exported them in JPEG format from Shutterstock, so perhaps the import to GMS didn't really make it look like an image with a transparent background. I used the PNG version and it's looking pretty. Thanks for your help!
Yeah, that would explain things. JPEG format has no transparency whatsoever so whenever you export a semi-transparent image to it, some kind of background will be added.
At any rate, glad you got it to work. ^^
 

woods

Member
i can crop and color for about an hour.. then my eyes are bleeding..... i can do it, but dam its rough...
its hard to find free good art out there. i gotta hand it to those pixel changer guys. they dont get paid near enough for what they do ;o)
 
Top