Detect single color overlay area with ImageMagick - image-processing

I have a bunch of images that have a single color overlay with some text on it positioned at the bottom. Not all images have the overlay and the overlay is not of the same height on every picture.
I am looking for a way to detect the overlay rectangle, and crop only the part of the image without it.
Trim seems the logical way to go, but the text on the overlay makes trim remove only the part below the text.
Any ideas would be welcome.
Thanks!

Make a copy of the image and crop it to just the left-most 5 pixels (assuming that there's some left margin to the text), trim and find out the new height. Then use the height of that trim to crop the original.

Related

IOS: Dynamically draw shape with wave divider in Swift (Bezier Curve)

Initially I have 2 backgrounds images (I use here 2 rectangles for simplicity, a green one and a grey one) the rectangles height is dynamically adjustable and I need to draw the black wave divider (also a custom image with gradient) between them as you can see in the image. I've tried to simply crop the backgrounds with the divider and merge them, but because the height (first rectangle will have a different height than the second one) is adjustable it will mess up the wave divider. It is not enough to draw the divider, also the rectangles should be cropped to match the divider form. Everything should be done programmatically in Swift and a pdf document will be generated in the end. I can only think to Bezier Curve (CGMutablePath, UIBezierPath), but I don't know exactly how to achieve it. Thanks a lot!
Shape I need to obtain
Grey Rectangle
Green rectangle

iOS 'colorWithPatternImage' is adding 1 px borders around my images?

I'm using UIColor's colorWithPatternImage function to set a tiled image on one of my views. The result is a grid of 1 pixel lines all over.
Fig: The clear color grid of lines is the issue.
My intention was to obtain a perfect background using the tiled image.
I first suspected that the image I was using could be faulty, but zooming it to 800% doesn't really show the presence of any transparent one-pixel border anywhere.
Here's the image (#2x version):
Any ideas what it could be related to?
Thanks,
p.
you are doing everything fine, but your problem is that your pattern image have 1 pixel line on the top an 1 pixel line on the left side with alpha color so you only need to modify your pattern image simply as that, I have been testing and this is the problem
I hope this helps you

How to slicing image and make it stretchable with image assets

stretch image right and left side
centre arrow remain as it is
i tried with it but centre down arrow position is not properly set by me.
You can't do this with sliced images.
The area between the edges will stretch or repeat in order to fill the area. You can't also preserver the centre section of an image this way.
What you might be better doing is creating a custom drawn view using either CALayer or drawRect.

Xcode 5 Image Slicing

I'm trying to slice an image in assets Xcode 5. I don't know if what I'm trying to do is possible with slicing.
The image looks like this:
I need to change the width and the height of the image, although not at the same time. The closest I've got is when I use Horizontal for the height and Vertical for the width. The problem is when I change the width, the left side of the image starts as a straight line and the skews and change to the original shape.
I'm about to give up on the idea of slicing and just create three images, left, center and right. Is that the only way to go?
This is how my current slice looks like:
Is there any way to change it so it works at least for the width?
UPDATE
Instead of slicing the image I used a mask and moved the mask.
Slicing works by taking the center section, and stretching it to fill the required space and then putting on the image end caps.
Because your button has a continuous diagonal line you will not be able to slice it. It will stretch the image out like so:
In fact even if you make a centre section and end caps you will still have the same issue as this image can only be scaled.
If you only need a finite set of heights then you should create individual assets for each height that can be sliced horizontally. If you need N heights then you should look into using core graphics to draw your shape in code in a -drawRect: method for arbitrary dimensions.
P.S. if you want to horizontally slice so you can grow the width its most optimal to have only 1 pixel width of image that will be stretched out so your button image resources would look a bit like this:
Aha. TIL: You can change the slicing options from the attributes inspector in the right hand pane in Xcode. To make your slicing work choose only "Horizontal"

make button glyph have a transparent background in delphi 7?

I have four TSpeedButton objects, each with a BMP file assigned as a glyph for the button image. For whatever reason, delphi has decided that two of the button images should have a transparent background and two should have a white background. I created the bitmaps myself, so they are all saved at the same color depth and are using pure white (not some shade of almost white) for the background and have background color in all four corner pixels of the image.
Why would some of the glyph images show up with a transparent background and some not? What is the criterion for making the background transparent? How can I make my button images all have transparent backgrounds instead of half of them having transparent backgrounds?
Ken's comment
Delphi's glyph handling uses the pixel in the lower-left corner to determine the transparent color. All pixels that match that color should be shown as transparent. Does the lower-left pixel color match in all of the glyphs, and does it match the areas you want to be transparent? (Without the images, it's hard to tell what the problem is, but I thought I'd post this as a potential for investigation.)
appeared to hold the correct answer (sorry, can't accept a comment as the right answer!). The image I was using had a shadow reaching to the lower left corner so it was almost white in that corner and exactly white in all the other corners.
I had a similar problem with D5 and I cludged a fix for this as I never found out why it was happening.
Define the image size one Row taller than the actual image/glyph is. This will force the image to be written starting at the top left and stop just before the last row. That will force the use of a non-transparent color and the extra row below the image is not visually noticeable.

Resources