ImageMagick stretchable image - imagemagick

In iOS there is a concept of stretchable images, i.e. a way to define regions of an image where the underlying image data can be duplicated in an aesthetically pleasing way:
Is there any way to specify this with ImageMagick's resize option (for instance as part of a composition operation)?
My final goal is to have this kind of overlay fit nicely to any aspect ratio of background picture:

Related

Hide smaller image portion, not overlapping with larger image in the background

I have two images, one larger than the other. My need is to be able to drag and place the smaller image anywhere above the larger one. The problem is that, I don't want the portion of the smaller image outside the larger image's boundary to be seen. Once the smaller image's non-transparent portion stops overlapping the larger image non-transparent portion, the non-overlapping smaller image portion should be hidden.However, when the smaller image is completely inside the larger image's non-transparent portion, it should be visible.!
[For eg., the image shown consists of a larger image that is a T-shirt and a smaller image that is of a lady.I want to add the image of the lady over the T-shirt. It should be possible to move the image of the lady anywhere inside the T-shirt.And once the image of the lady moves out of the T-shirt's outer black boundary the non-overlapping portion of the image of the lady should become transparent. Here, the portion of the T-shirt image outside the black boundary is transparent. Can someone help me with the code?
Your requirement is a pretty complex one. If the "T-Shirt" part is static than again it is easy for you to mark boundaries for that image. But if there is different background than you need to do more stuff.
Here you have to take a help of Core image. You need to process that image and get the core details of that image. Also "Morphological Operations" will help you to detect object from image. Take a look on links:
Core image processing
Morphological Operations
Also about the drag and drop follow this one.
OBDragDrop

Trim UIImageView to fit content

Does anyone know how I could trim a UIImageView of some image with surrounding transparency down to just barely fit the content by cropping off the edges?
You can try using this category:
https://github.com/Clstroud/UIImage-Trim
Here is a usage example from their docs:
UIImage-Trim Category for trimming transparent pixels of an UIImage
object.
How to use
Add the UIImage+Trim files to your project. Include UIImage+Trim.h in
the files where you want to trim your images.
Trimming is pretty straightforward:
[yourImage imageByTrimmingTransparentPixels];
Optionally, you may want to consider any non-opaque pixels as being
transparent (for instance, cropping out a light drop shadow). This can
be achieved by using the alternate method:
[yourImage imageByTrimmingTransparentPixelsRequiringFullOpacity:YES];
Additionally, if you merely desire to know the UIEdgeInsets of the
transparency around the image, you may want to use the following:
[yourImage transparencyInsetsRequiringFullOpacity:YES];
This call works based on the same principles as the "advanced" trim
method, with the boolean dictating whether non-opaque pixels should be
considered transparent.

How to get rid of empty transparent areas in a PNG image so that it conforms to actual image size?

I have a series of images that I would look to loop through using iOS's [UIView startAnimating]. My trouble is that, when I exported the images, they all came standard in a 240x160 size, although only 50x50 contains the actual image, the rest being transparent parts that are just taking up space.
When I set the frame of the image automatically using image.size.width and image.size.height, iOS takes into images' original size of 240x160, so I am unable to get a frame that conforms to the actual parts of the image. I was wondering if there is a way using Illustrator or Photoshop, or any other graphics editing software for me to export the images based on their natural dimensions, and not a fixed dimension. Thanks!
I am a fan of vector graphics and thinks everything in the world should be vector ;-) so here is what you do in illustrator: file - document setup - edit artboards. Then click on the image, and the artboard should adjust to the exact size. You can of course have multiple artboards, or simply operate with one artboard and however-many images.

UIViewcontroller image dimensions

I wanted to display a png image in the center of my main view controller. Do I have to use a UIImageView or just add the image to the view itself?. I don't want to cover the whole view but just in the center with a fairly large image. What would be the ideal dimensions of the image be for all iOS devices (supporting iOS 6.0 and above)?.
The easiest way is to use UIImageView like you said. There are ways of manipulating other classes to display images, but it's more code overall and more confusing to look at. As for the ideal dimensions, it depends on the aspect ratio of your image and the rest of your view.

How to apply a soft shaped shadow to graphics which have transparent areas in them?

Normally I'm using CALayer shadowRadius, but now I also need to use UIImage and apply shaped shadows to it based on the content in the image.
For example when I have a layer with text in it and I set a shadow, it works automatically on the text and not just on the rectangle of the layer.
In Photoshop this is known as "layer style" and it automatically works based on the shape of the image content.
I am afraid that I need to implement some Harvard-Stanford-MIT-NASA kind of hardcore logic to apply a shadow on a "shaped image", i.e. an image of an round icon where the areas around the icon are fully transparent.
I'm able to manipulate images on a per-pixel level as I'm doing this already to draw charts, so if there was an open-sourced implementation of some fantastic algorithms this would be fantastic. And if not: How does this basically work? My guess is I would "just" try to blur a grayscaled version of my image somehow and then overlay it with the non-blurred version.
My guess is I would "just" try to blur a grayscaled version of my image somehow and then overlay it with the non-blurred version.
That's pretty much it, actually. Except instead of blurring a greyscaled version of the image, blur a solid-colored version of the image (i.e. keep the alpha channel, but make all pixels black). Although CALayer's shadowing should do this already for you.
If your images are already composited onto a background (i.e. without real transparency), you have a harder problem as you first need to "remove" the background before you can have the shape of the object in order to generate the shadow.

Resources