GraphicsMagick adds black surroundings to transparent image - node.js

I'm using GraphicsMagick for node.js and I'm trying to edit the attached image but unfortunately it adds a black contour and I don't know why. Maybe it it because I transform it from png to jpeg? Any help is much appreciated!
gm(image.file.path)
.quality(70)
.strip()
.samplingFactor(4, 2)
.interlace('JPEG')
.colorspace('sRGB');

I don't speak node but try something like this to set the background colour to yellow and then flatten the image with transparency over the top.
gm(image.file.path)
.quality(70)
.strip()
.background('yellow'),
.flatten()
.samplingFactor(4, 2)
.interlace('JPEG')
.colorspace('sRGB');

Related

Image manipulation in Node JS

I am new to node js and I want to convert a png image to pure black and white (not grayscale) image using native node js libraries. All I know that bit depth of black and white image should be 1. Any help is appreciated.
You have 2 options, both with the same package
https://www.npmjs.com/package/gm
Docs : http://aheckmann.github.io/gm/docs.html
Option 1
Convert the image in to monochrome
gm("img.png").monochrome()
Option 2
Use black and white thresholds to manually specify the ranges to be converted to pure black and white
//pixels below `threshold` become black.
gm("img.png").blackThreshold(red ,green , blue , opacity)
//pixels above the threshold become white
gm("img.png").whiteThreshold(red, green, blue, opacity)
Docs
http://aheckmann.github.io/gm/docs.html#blackThreshold
http://aheckmann.github.io/gm/docs.html#whiteThreshold
Personally I think Option 2 suits your needs best.

Coloured textures for POIs

I was trying to use a coloured texture (PNG 24/RGB) for a POI (bicycle_parking) and it was not being rendered. It was added properly as a texture, it just won't be rendered on the POI.
After some testing I came to believe that POIs only accept grayscale textures that can later be filled up with a color. Is this right?
I also found out that the icon needs to be of a specific size (I got it working only at 32x32 pixels and 512x512, but the scaling did not make it look good). Is there any information regarding this?
Now I have a grayscale icon (mostly white) but the fill color does not change the white as expected. This is as far as I got..
Here's a set of icons similar to the ones I need to render into POIs
How could I achieve adding this type of icons as the texture of a POI? Workarounds/hacks are welcome as well :)
Thanks!
The texture of the Poi must have a size that is a power of 2 and goes from 32x32 up until 512x512. Also make sure that the colour code of that image is RGB anything else wont work. For the best visual result you have to create 3 sets of pngs for different screen densities, for example see heatmap_legend.png then look at heatmap_legend#2x.png and heatmap_legend#3x.png, you can find them in the "common" folder.
So turns out that the color wasn't a problem after all. It was quite tricky to get one image working, but once I had the image working, adding color to it and saving the PNG worked just fine.
The problem with the image size I experienced is still happening. You need to export it in 32x32, 64x64 or 96x96 in order to StyleEditor not to crash when opening the file.

Create an Image either using Magick Wand or ImageMagick on Python 3

There's not enough information on Internet about imagemagick and magick wand on Python 3. I need to create a lot of images using Python 3, creating the images with a background color or a background image.
When I get the image with the background I want, then I need to add text with a font of my preference on It, I think I can solve the problem of the font, but how to add the "string" in the image?
After that, I want to save the image with a "name".
I have installed Magick wand and Image Magick on Python 3, but the documentation is in a language that I really don't understand. Do I need to install something else?
If you're able to help me, it would be great. Thank you!
You can achieve these using Wand.
Creating the images with a background color or a background image
Add text with a font
Save the image with a “name”

Pixlelated borders when i save image as GIF with Transparent In Illustrator

World Map Images in Adobe Illustrator CS5
I have an image Map in illustrator CS5 which i want to save in GIF so as to reduce its size for web use. But when i save it, the map boundaries are having some white pixels all along the map boundaries of map.
I really dont know why has happened to it, but cant save it in Png-8, png-24 formate due to size constraint.
Any meaningful answer will be highly appreciate and thanks in advance.
Is your background a non-changable color? Maybe you can save the image with the same color as a background.
The problem is gifs don't support true transparency.
If this doesn't work can you provide the image you are trying to save (gif and png, I don't have AI right now)? Maybe there will be something I can do about the size or clearing the gif's edges.
transparent GIFs don't have an 8-bit alpha channel, like PNG does: a pixel in a GIF is either there, or it's not: if it's there, you can't see through it. This often means that an edge between transparent and non-transparent areas looks blocky.
There are two ways to deal with this... either use a PNG 24 (and the Illustrator Save for Web feature will help you to make it smaller), or in Illustrator create a background color layer behind your image before you export to GIF. If this background color layer is the same as the website you put the image on, the edges will blend nicely.

set unwanted color to transparent

let say photoA got 100 color, i want to generate a transparent photoB with only 10 wanted colors. by using -transparent of 90 colors is too troublesome, any idea ?
thanks TobiasE, your answer is helpful.
i try the command below,
convert map.gif +transparent "#26fffe" newmap.gif
but it show error msg below:
convert: unable to open image `#26fffe': No such file or directory.
any idea ?
If the colors you want to make transparent is similar to each other you can use the -fuzz setting.
If the colors you want to keep visible is similar to each other you can use the -fuzz setting and use +transparent instead of -transparent to invert the matched pixels.
Straight from the documentation:
-transparent
...
Note that this does not define the color as being the 'transparency color' used for color-mapped image formats, such as GIF. For that use -transparent-color

Resources