How to save UIImage as a SVG file - ios

The image draws with bezierPath, and I want to save it as a SVG file.
The format I can see are PNG or JPG.

You can't, at least not while using UIImage. Read the class doc...
UIImage Class Reference
Supported Image Formats
Table 1 lists the file formats that can be read by the UIImage class.
Supported file formats
Tagged Image File Format (TIFF)
.tiff, .tif
Joint Photographic Experts Group (JPEG)
.jpg, .jpeg
Graphic Interchange Format (GIF)
.gif
Portable Network Graphic (PNG)
.png
Windows Bitmap Format (DIB)
.bmp, .BMPf
Windows Icon Format
.ico
Windows Cursor
.cur
X Window System bitmap
.xbm
However, this kit may help...SVGKit. It interacts with Core Animation.

If you have a bezier path, you do not want to save it via a UIImage. You can convert it directly to an SVG path string, and insert that SVG path into an SVG document.
See for instance this answer: Converting UIBezierPath to SVG answer

Related

PDF vector graphic smaller than the png at same size

I converted some SVG images into PDF and png files for my iOS app. When adding them to the UIImageView, the pdf images look smaller than the png equivalent. The scale type was set to center, so no scaling happens at runtime.
btw, the pdf and png look the same when I open them in preview and adobe reader
Anyone had same issue and got a solution for that?
When converting an SVG to PDF, make sure the DPI is set to 72. That way, the size will match with the PNG resource that you have. Xcode actually expects vector-based resources to be 1x in size.

How to set colorspace of PDF generated with UIKit?

I'm trying to generate print-ready PDFs using UIKit (UIGraphicsBeginPDFContextToData, etc.). One of the requirements from the printer is that the PDF be in a greyscale colorspace. I'm generating a PDF directly from a UIView that contains a UIImageView and a few UILabels.
I checked and the PDFs generated by default are in an RGB colorspace. This might be a holdover from the UIImageView, who's image is in RGB colorspace (not sure how to change that either).
Any ideas?

Canvas data Export fabric.js

i want to know that what is the good method to export the data for Canvas with fabric.js,
Let's say, I have four images, 123.ai, 123.eps, 123.svg, 123.jpg. Now while adding on Canvas, with imagemagick I am converting it to png, So all the images will converted to .png extension, and then with .toSvg method I am exporting the Canvas data, So in SVG i am getting the reference path of the png files only, which are converted and added to the canvas. Now Actually while opening in illustrator, SVG takes references of png files instead of original files, So is there any ways I can retain original files while using method .toSvg . So i can direct open in illustrator, While If i make any in .Ai file, so that update would automatically updated in SVG file, if it takes the reference of original files instead of converted png file.
Or is there any way i can use another method?
First of all fabric js is working perfect with illustrator saved file. So if there is any file saved with illustrator in any format will have accurate output in canvas.
Second thing, as you said, that you are also working with SVG files. So it is ideal way to add SVG files to canvas and export canvas to SVG so you will not have any reference to any PNG files. you have smooth and straight forward way that you will add SVG files and export SVG file.

Delphi - Resize PNG with transparence and index

I have many PNG files with transparency and these PNG fiels seem to be indexed.
I would like to :
Put 2 identical PNG side to side with a space between both
Resize the result with a smooth resize filter (or Mitchell, Linear, Spline or other)
Keep transparency and originals colors
Do you have an example to do that ?
This question is related to other PNG resize questions but...
AFAIK, You can't resize an indexed image and keep the original palette. Resizing the image will necessitate the mixing of colors, especially in reducing the image.
The original author of the PNGImage component (the basis of the Delphi native component) had a forum where he, and others, posted code snippets on how to do things using the PNGImage component.
Before the forum was taken down I grabbed a copy of all of the code snippets and placed them on the CodeGear Code Central website.
Most if not all of these work with native PNG images and do maintain the Alpha channel.
Here is the complete list of examples included in the package:
Smooth rotates a PNG object
Resizes a TPNGObject using a smooth algorithm
Slice one PNG into several smaller ones
Saves an image as either a bitmap or a png.
Sample chunk descendant
Read all tEXt-Chunks and write values into a TStrings object
Display a message box with information extracted from the PNG File
Finds and cuts a block from a PNG image
This method converts the png into a jpeg object
This method converts the png into a bmp object
Overlay one PNG over another (This makes the image half transparent)
Flips a png image vertically and saves back
Draws a png image over the desktop
Here is the link: CodeCentral PNG Methods

Only convert images of a certain file type with paperclip styles

I want to convert uploaded images that are not jpegs or pngs to to be jpegs or pngs using paperclip. Problem is i dont want to convert jpegs to pngs or pngs to jpegs, just leave them as the file type they are.
Is this possible ? If so how do i create the styles all in jpeg or png ?
Also what is the best file type to save as? I cant convert some pngs to jpgs as if they had transparency in that gets lost / changed. Also if i change all to png is not bigger and alos i am using Prawn pdf outputting these images so cant use gif.
Any pointers anyone ?
Thanks alot
Rick
In order to do this you will need to create a custom Paperclip::Processor. You can probably subclass the Paperclip::Thumbnail in doing so.

Resources