image-manipulation

Manually alpha blending an RGBA pixel with an RGB pixel

ぐ巨炮叔叔 提交于 2019-11-28 06:24:47
I am trying to do an alpha blend operation of an RGBA image (foreground image), on to a RGB image (background image). However, while doing so I think I may be doing the wrong alpha blending operation or doing it wrong. For example, the pixel of my RGB image is a grayish color of (127, 127, 127). The pixel of my RGBA image for the pixel will be (0, 0, 255). After I do my blending operation, the final color will be (127, 0, 255). However, I thought that was more of an additive blend and different than the operation I am doing. For how my values are set, take a look at this incPixelColor[0] = 0;

PIL how to scale text size in relation to the size of the image

北战南征 提交于 2019-11-28 06:20:36
I'm trying to dynamically scale text to be placed on images of varying but known dimensions. The text will be applied as a watermark. Is there any way to scale the text in relation to the image dimensions? I don't require that the text take up the whole surface area, just to be visible enough so its easily identifiable and difficult to remove. I'm using Python Imaging Library version 1.1.7. on Linux. I would like to be able to set the ratio of the text size to the image dimensions, say like 1/10 the size or something. I have been looking at the font size attribute to change the size but I have

How to save a GIF on the iPhone?

时光怂恿深爱的人放手 提交于 2019-11-28 06:18:11
问题 how can I save a GIF on the iPhone? The SDK includes only UIImageJPEGRepresentation and UIImagePNGRepresentation but nothing for GIFs or other image formats, is there a way to convert a UIImage to a GIF and save it? GM 回答1: This is a library I wrote for encoding GIF images on the iPhone, if anyone reading this is interested: http://jitsik.com/wordpress/?p=208 回答2: You can't without a third party GIF library. The question is why do you need it to be GIF? PNG provides all that you might need

Tint image using CSS without overlay

痴心易碎 提交于 2019-11-28 05:46:29
Is it possible to tint an image with a specific color using CSS without an overlay in a WebKit browser? Failed attempts Managed to tint the image sepia or an arbitrary color using hue-rotate but couldn't find a way to tint it with a specific color. Creating a "tint" SVG filter and calling it with -webkit-filter: url(#tint) doesn't work on Chrome. All possible combinations of opacity / box-shadow css properties with drop-shadow / opacity filters don't generate the desired effect. Ideas Given a color, wouldn't it be possible to combine the HSB filters ( hue-rotate , saturation , brightness ) to

GD! Converting a png image to jpeg and making the alpha by default white and not black

余生颓废 提交于 2019-11-28 05:03:35
I tried something like this but it just makes the background of the image white, not necessarily the alpha of the image. I wanted to just upload everything as jpg's so if i could somehow "flatten" a png image with some transparently to default it to just be white so i can use it as a jpg instead. Appreciate any help. Thanks. $old = imagecreatefrompng($upload); $background = imagecolorallocate($old,255,255,255); imagefill($old, 0, 0, $background); imagealphablending($old, false); imagesavealpha($old, true); <?php $input_file = "test.png"; $output_file = "test.jpg"; $input = imagecreatefrompng(

Create a BufferedImage from file and make it TYPE_INT_ARGB

假装没事ソ 提交于 2019-11-28 04:56:15
I have a PNG file with transparency that is loaded and stored in a BufferedImage . I need this BufferedImage to be of TYPE_INT_ARGB . However, when I use getType() the returned value is 0 ( TYPE_CUSTOM ) instead of 2 ( TYPE_INT_ARGB ). This is how I load the .png : public File img = new File("imagen.png"); public BufferedImage buffImg = new BufferedImage(240, 240, BufferedImage.TYPE_INT_ARGB); try { buffImg = ImageIO.read(img ); } catch (IOException e) { } System.out.Println(buffImg.getType()); //Prints 0 instead of 2 How can I load the .png, save in the BufferedImage and make it TYPE_INT_ARGB

I can't use transparent background with imagecopymerge

*爱你&永不变心* 提交于 2019-11-28 04:27:04
问题 I am calling imagecopymerge($dst_r, $logo, 0, 0, 0, 0, $LogoX, $LogoY, 100); where $logo is a png file with transparent background. From some reason the background comes out white instead. What am I doing wrong? Thanks. 回答1: You need to use imagealphablending($dst_r, TRUE); to allow copying with retaining the transparent colors. Many more comments (...) in the manual suggest using imagecopy instead, because imagecopymerge was never intended to be used with transparency. If you use pct=100

Detecting hair in a portrait image?

笑着哭i 提交于 2019-11-28 04:25:35
What would be the best approach for detecting and removing a person's hair in a simple portrait image ? Any useful libraries of algorithms ? I have been looking over openCV which looks like it could be of some use You're dealing with two different problems here: detecting if a face in a portrait has hair "removing" the hair The first is solvable fairly easily: Separate the face from the background (as you've mentioned a "simple portrait image", this shouldn't be too hard). Convert your image to the Y'CbCr color space Human skin has a fairly narrow range of chrominance values, regardless of

Proportional image resize

拟墨画扇 提交于 2019-11-28 03:29:05
I'm having a little bit of a problem scaling my images to a properly predefined size. I was wondering - since it is purely mathematics, if there's some sort of common logical algorithm that works in every language (PHP, ActionScript, Javascript etc.) to scale images proportionally. I'm using this at the moment: var maxHeight = 300; var maxWidth = 300; var ratio:Number = height / width; if (height > maxHeight) { height = maxHeight; width = Math.round(height / ratio); } else if(width > maxWidth) { width = maxWidth; height = Math.round(width * ratio); } But it doesn't work properly. The images

Resize Image to fit in bounding box

倖福魔咒の 提交于 2019-11-28 03:20:17
An easy problem, but for some reason I just can't figure this out today. I need to resize an image to the maximum possible size that will fit in a bounding box while maintaining the aspect ratio. Basicly I'm looking for the code to fill in this function: void CalcNewDimensions(ref int w, ref int h, int MaxWidth, int MaxHeight); Where w & h are the original height and width (in) and the new height and width (out) and MaxWidth and MaxHeight define the bounding box that the image must fit in. Shawn J. Goff Find which is smaller: MaxWidth / w or MaxHeight / h Then multiply w and h by that number