How to cache JAMSVGImage into disk - ios

this issue has troubled me for some time。i should allow user to scale image,so i choose svg instend of jpg/png ,one of question is that i hava to store svg because such svg resource are loaded form netWork,but i find that if i archiver svg into data,read data from disk transform to svg,it cost some time to render svg。so i change other method ,i want to archiver JAMSVGImage instance ,but what i stuck in is that i can't find any way to archiver JAMSVGImage。now i just cache JAMSVGImage into memory with singleton,but as we all know,every time when the app has killed or stop running background ,we lost the cache data in singleton,who can help me to slove this issus,thanks!

What you probably want to do is store the SVG, render it to a new UIImage (using JAMSVGImage's imageAtSize: method), and store a PNG representation of that UIImage in your application's cache directory.
When you application starts, you check whether the corresponding PNG in the cache directory exists and load that instead of the SVG. You would then only load the SVG when you really need it, for example when resizing.

Related

How can we take the new virus that has the extension called MZTU out or removerd and restore my folders?

I had some words and pdf files,and then suddunly I am unable to open them,due to the extension of the pdf had altered to Mztu.How to return my data and the files?
It would be an honor, if you inform me how to deal with it to remove it and return my data.
All wishes.
I tried to copy the files into my flash, and I look forwred it in the start windows, but i didnot find it.

Edit Photos via Photoshop on a server

I wart to create a web app where a user enters certain data via a form and then receives a custom rendered image. The image is from a smart object in a psd. It's kind of like a mock-up which definitely requires needs some photoshop filters to be properly rendered.
This should all happen in real time and should be doable from my understanding since the rendering of a single images doesn't need much computing power
I've done some research and haven't really found a solution the matches my problem. Is it necessary to run Photoshop on a server and then remotely run a photoshop script and then upload the generated image somewhere else?
I've used The After Effects Plugin Template by DataClay in the past which offers similar functionality but for video.
Looking forward to hearing your ideas.
Thanks
You can use the Dataclay plugin to handle still image exports out of After Effects. Make a single-frame duration composition in After Effects and rig the layers with the Templater plugin. Then use the PNG Sequence output module to render out a single frame.
From Dataclay's forums:
Exporting
A few extra steps are required to correctly render a project file as a PNG sequence using Templater. By default, a file rendered as a PNG sequence will have the frame number appended to the end of the file name, i.e.:
filename.png00000, filename.png00001, filename.png00002, etc.
In order to designate where in the filename the frame number should be added, we’ll need to use the output column. First, add a column named output to your data source. Next, add a filename with a set of brackets with five # signs to designate where the frame numbering should be added. For example:
filename[#####] would result in filename00001.png
or
[#####]filename would result in 00001filename.png

How to inject exif metadata into an image, without copying the image?

I have previously asked this question: How to write exif metadata to an image.
I now have found a way to inject metadata. However, it results in a copy of the image into memory. With large images, and the need to already have a copy in memory, this is going to have performance, and possibly cause a memory crash.
Is there a correct way to inject metadata without having to make a copy of the image? Perhaps it could be tacked on to a file, after it is written to disk?
I would prefer native implementations, without having to resort to a third party library just for this, if at all possible.
This question could require a small or large amount of code depending on what you need. EXIF data is stored in a JPEG APP1 marker (FFE1). It looks very much like a TIFF file with a TIFF header, IFD and individual tags with the data. If you can build your own APP1 marker segment, then inserting it or replacing it in a JPEG file is trivial. If you are looking to read the metadata from an existing file, add some new tags and then write it back, that can be more involved. The tricky part of EXIF data are those tags which require more than 4-bytes. Each TIFF tag is 12 bytes: 2-byte tag, 2-byte data type, 4-byte count, 4-byte data. If the data doesn't fit completely in the 4 bytes of the tag, then the tag specifies an absolute offset into the file of where to find the data. If the existing data has any tags with data like this (e.g. make, model, capture date, capture time, etc), you will need to repack that data by fixing the offsets and then add your own. In a nutshell:
1) If you are adding a pre-made APP1 marker to a JPEG file, this is simple and requires little code.
2) If you need to read the existing meta-data from a JPEG file, add your own and write it back, the code is a bit more involved. It's not "difficult", but it involves a lot more than just reading and writing blocks of data.
Start by reading the TIFF 6.0 spec to understand the tag and directory structure:
TIFF 6.0 spec
Next, take a look at the JPEG EXIF spec:
EXIF 2.2 Spec
I would expect the existing exif manipulator software can do it, but haven't tested.
Links:
http://www.exiv2.org/
http://libexif.sourceforge.net/
http://www.kraxel.org/blog/linux/fbida/
CGImageSourceRef could be used to get image properties including its thumbnail without loading all image data into memory. This way memory is not wasted by UIImage and NSData.
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path], NULL);
Then save CGImageDestinationRef adding the source image and exif data.
CGImageDestinationAddImageFromSource (destRef,
imageSource,
0,
(CFDictionaryRef)propertes );//exif
BOOL success = CGImageDestinationFinalize(destRef);

rails + paperclip saving images and doc/pdf/txt file as well

My model can save images and also doc files,
If user save the images then it should be save in three sizes like small/big...
If user save doc then It should be save as normal document
Anybody can help me....
You can write proc in the styles definition, so you at process time define styles. If there no styles the original file saved only, without processing. See more here at Dynamic Configuration section.

Rails: possible to check if a string is binary?

In a particular Rails application, I'm pulling binary data out of LDAP into a variable for processing. Is there a way to check if the variable contains binary data? I don't want to continue with processing of this variable if it's not binary. I would expect to use is_a?...
In fact, the binary data I'm pulling from LDAP is a photo. So maybe there's an even better way to ensure the variable contains binary JPEG data? The result of this check will determine whether to continue processing the JPEG data, or to render a default JPEG from disk instead.
There is actually a lot more to this question than you might think. Only since Ruby 1.9 has there been a concept of characters (in some encoding) versus raw bytes. So in Ruby 1.9 you might be able to get away with requesting the encoding. Since you are getting stuff from LDAP the encoding for the strings coming in should be well known, most likely ISO-8859-1 or UTF-8.
In which case you can get the encoding and act on that:
some_variable.encoding # => when ASCII-8BIT, treat as a photo
Since you really want to verify that the binary data is a photo, it would make sense to run it through an image library. RMagick comes to mind. The documentation will show you how to verify that any binary data is actually JPEG encoded. You will then also be able to store other properties such as width and height.
If you don't have RMagick installed, an alternative approach would be to save the data into a Tempfile, drop down into Unix (assuming you are on Unix) and try to identify the file. If your system has ImageMagick installed, the identify command will tell you all about images. But just calling file on it will tell you this too:
~/Pictures$ file P1020359.jpg
P1020359.jpg: JPEG image data, EXIF standard, comment: "AppleMark"
You need to call the identify and file commands in a shell from Ruby:
%x(identify #{tempfile})
%x(file #{tempfile})

Resources