download from rails to iphone zipped file missing portions - iphone

I'm using send_file to download a zipped file consisting of multiple images, from my rails server to my iPhone. On Rails I am using Zip::ZipOutputStream.put_next_entry which I think comes from rubyzip. On the iPhone I am using ZipArchive to unzip the file back into multiple files into memory using UnzipFileToData. The problem I run into is that the bottom portions of the images are black by random amounts. Some images have no blacked out portions, others have up to half of the bottom part of the image blacked out. The images are small, around 20 KB in size.
The problem I have is that I cannot figure out what portion of the path from rails to iPhone is causing the images to have their bottom portions blacked out.
1. I've ftp'ed the zipped file from my Rails server to my Mac and unzipped them and the images look fine, which means the images are getting zipped on the Rails server correctly.
2. I've tried reversing the order that the images are added to the zip file, but the same amounts of the bottom of the images are blacked out.
3. Could it be that different compression levels are being used?
Anyone have any idea why the unzipped images from a multi-file zipped file would be missing random parts of the bottom part of the images?

Found the solution here. My rails code originally looked like:
Zip::ZipOutputStream.open(zipped_file.path) do |z|
user_photo_array.each do |file|
z.put_next_entry(File.basename(file))
z.print IO.read(file)
end
end
and as the link above noted, IO.read is problematic for binary files, so I followed the link's suggestion and replaced IO.read with File.open(file, "rb"){ |f| f.read } as
Zip::ZipOutputStream.open(zipped_file.path) do |z|
user_photo_array.each do |file|
z.put_next_entry(File.basename(file))
z.print File.open(file, "rb"){ |f| f.read }
end
end
and that fixed the problem!

Related

Responsive FileManager Upload Window Too Small

I am using Responsive FileManager 9.10.1 (although this problem existed from previous 9.x.x versions as well): when the folder I'm browsing has just one line of files (e.g. if it's empty), and then I click upload, the RFM window doesn't grow larger, making it a very uncomfortable upload.
Is there some config option to enlarge the window? Is this a real RFM issue or is it just me?
The only way I've found to get around this is the "hacky" way: the class for the viewing area in RFM is called fancybox-inner. If its min-width is set to 580px, the upload iframe will fit perfectly inside.
This doesn't solve the problem of uploading a whole lot of files in a way that the upload window's height becomes higher, however, for most practical purposes it works.

Rendering Images inside PDF, images not being rendered in PDF Viewer 0.1.8

Please check updates as they have additional informations... Apparently located the problem in a specific pdf client but cannot close the issue with an open bounty...
I am generating a pdf using grails rendering plugin. The PDF has a couple of images inside and "some" of them are not being outputted!
I am rendering the images inline via data uris as required by the plugin. That means that all my images are something like:
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQECWAJYAAD...">
If I render them in a normal html view, I can see the images just fine!
If I render the template to a JPG/PNG with the same plugin, again the images render all fine.
If I render to PDF the images which are being retrieved by an octed-stream are broken!
Something like:
Looks like the image started to render and then something happened...
It is happening on the big-sized images, but also on the thumbnail version of same image.
Any one has some hints as why this might occur?
UPDATE
The file which does not show up is a file with mime application/octet-stream
So apparently I can retrieve the bytes from the file, but when they transmitted for PDF Rendering, the image does not appear...
Yet another update
The issue seems to be related with the PDF Viewer. Was using a Linux based PDF Viewer (PDF Viewer 0.1.8) and specific images are broken. In all other PDF Viewers I could test everything works fine.
Cannot close the issue as there is a bounty open :( Sorry that the bounty and question seems meaningless now, but you never know, someone might have an idea how to solve this even for PDF Viewer 0.1.8.
<img src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQECWAJYAAD...">
works fine for me. Note the missing "e".
You can use rendering tag:
<rendering:inlineJpeg bytes="${your-image}" />
Make sure you decodeBase64() your image.

Why does one of my pngs have a query string attached?

I'm not using any WP cache plug ins. I've noticed that only one png out of the other pngs (and other images) I have on my WP site has a query string attached to it when I look at in Chrome dev tools. It's actually downloaded twice - with and without query string.
The other odd this is that Chrome Dev tools says that the intiator for the png with query string is jQuery. I just include jQuery from Google's CDN, so I'm not changing anything.
Any ideas to why just one of my pngs (why this one?) has a query string attached? Here's what it looks like:
<img src="http://www.mysite.com/wp-content/themes/myTheme/images/slide1Btn.png?1369071380764" alt="">
Please let me know if I haven't included enough information.
Edit
This png is a button on one of the slides I have in a slideshow. I use http://archive.slidesjs.com/ to generate the slideshow. The png images are part of the HTML markup and not generated by the script, however I did find this line in the slides.js code:
// gets image src, with cache buster
var img = control.find('img:eq(' + start + ')').attr('src') + '?' + (new Date()).getTime();
I would like to just have the png load once and just be retrieved from the cache on reloads - like each of the pngs will do on subsequent slides in my slideshow. I'm perplexed as to why it only happens to this png.
It might either be :
some argument for a script that dynamically generates or resizes or processes the image (it does not matter that the url has a .png extension, that doesn't necessarily mean that a png file is served statically)
a "cache breaker" - or "cache buster". This can be used to prevent the browser (sometimes also the server) to get the image from a cache, and force it to get it fresh from the server.
Because in this case this looks as a timestamp (unix epoch in milliseconds), I'd bet for the later.
wordpress generates many of the images dynamically, meaning when you access the png you are calling a server page that generates the png dynamically choosing between different images or based on the query string parameters, like size for exmaple.
200px width image.
http://mysite.com/wp-content/uploads/2013/05/Giant_water_bugs_on_plate.png&w=200&h=446&zc=1&q=100
vs
600px width image
http://mysite.com/wp-content/uploads/2013/05/Giant_water_bugs_on_plate.png&w=800&h=446&zc=1&q=100

One App, Multiple Branding

I have made an application for the iPhone but it is required to be released with multiple brandings. Eg Differernt:
App Name
Icons
Default.png
Text replaced for the app name in IB
Colour schemes for all images such as backgrounds, icons etc
I'm not sure of the best way to do this.
I was thinking of a plist file for each branding that would have the name of the files to load eg "brand1_background.png" for brand1 but that would get very messy with the text replacement. It would also mean that all brands images would be in the package making it of larger size.
Looking around a bit I could have an 'images' folder for each brand and drag it in to build that brand's app, however the text is still an issue.
I'm wondering how everyone else would handle this situation as I want to do it as right as possible.
There are 2 different aspects to this problem, which I'd describe as follows:
Stuff that can be changed dynamically
Stuff that can't be changed dynamically
The first category is super easy. If you have your colo(u)r schemes stored in some easily-readable format like a plist or whatever, you can just load up that file during app startup, and build UIColor objects from them and use those where appropriate. The same goes for images used within the app itself. This is not a hard problem.
The second category is trickier. This is stuff that has to be baked into the application because of code signing. This means that the things like the App Name, the icon, Default.png, etc, all have to be changed before the app is signed in the compilation process. So what I'd do is bake up a bunch of scripts to take your branding information (name, image files, icons, etc) and load it up, then generate your Info.plist file and whatnot. This should be done as one of the first phases of your compilation.
For what it's worth, I work on an application where we do exactly this process, and it works pretty well. It's a bit tedious to update when we change what resources get branded, but I'm not sure there's any decent way around that.
Create a target for each of your brandings. For each single target you can add different files (e.g. images) and set an app name. You can even use the same file names (but stored under a different location) and you can build your brand-apps pretty fast.

iPhone simulator shows app's images but iPhone does not

I have create an application on iphone using objective-c.In this application i am just displaying different players images stored in one folder, which will be run perfectly on simulator. But when I deploy it on iphone it is not showing the images of the player.
for that the code is:
UIImageView *imageplayer = [[UIImageView alloc]initWithFrame: CGRectMake(imgx, imgy+45,135,150)];
imageplayer.image = [UIImage imageNamed:playerpng];
if(imageplayer.image == nil)
[imageplayer setImage:[UIImage imageNamed:playerjpg]];
if(imageplayer.image == nil)
[imageplayer setImage:[UIImage imageNamed:#"noimage.png"]];
[self.view addSubView:imageplayer];
Plz solve this query.
Thanks in advance
Sometimes xCode doesent update correctly the bundle, try cleaning and building again.
I am currently experiencing this problem as well. I was able to correct it after a bit of debugging and reviewing the build file.
When I do an ls -l, I noticed that some of my png files have a # symbol beside the permissions. When I followed that up with a ls -l#, it showed that the files with an '#' had an attribute set 'com.apple.quarantine'. This attribute is given to a file (often from a zip, jar, or other executable) that is downloaded from the net. You can get rid of this attribute by performing:
xattr -d com.apple.quarantine *.png
Then, select the images in XCode, and check that the checkbox under the target is checked. In my case, it was not, so the images weren't being included in the bundle.
I had the same problem, solved by using all lowercase for the file name in code - image.jpg, but it does not seem to make any difference what case the actual file name is, e.g. Image.jpg
check name of image file. It must be "noimage.png"
not Noimage.png or noimage.PNG
Just to clarify, does the "noimage.png" display, or is the program loading a player image but failing to display it? Or is nothing loading.
These should easily be determined in debug mode.
A few additional things to check...
1) Just for testing, start out with PNG versions of the player files. This is the primary format on the iPhone and might eliminate a file format issue or other anomaly that the simulator is not sensitive to.
2) With regard to fixing in an image editor, specifically make sure that the image is set to a DPI of 72 pixels/inch. The iPhone and particularly Interface Builder are very sensitive to this being correct and will sometimes not display or will display a very blurred version of the image if incorrect.
3) Make sure the image(s) haven't been added multiple times (from different directories and/or to different group folders). We encountered a situation where we had inadvertently imported the same images at two different layers within the project hierarchy and this can cause unexpected behavior within the iPhone (selecting randomly or failing to select).
4) Make sure the Get Info -> Targets has your particular target checked. The simulator may still see the image but it will not get deployed to the iPhone.
5) Make sure you can view the image within XCode and that it looks correct.
Barney
This happens to me sometimes. I once spent half a night trying to figure out what was wrong. In this end, this is what worked: open the image with an image editor and save it again. That's all. I'm using the free Acorn image editor to do this. Haven't tried it with Photoshop. (After all, it seems that Photoshop might be responsible for introducing the error in the first place, although that's far from sure.)
I don't know what causes the problem. I usually get it when I use png files that have been sent to me. Could be a simple file permissions problem, or some more subtle problem with the image format. I would be very interested in hearing the opinion of better-informed people.
In any case, if all else fails just try this: open the image with Acorn, save over the original file. Works for me.
Make sure the image files are added to your XCode project.
After some investigation, Michael's comment seems to have a solved it for me. I had all lower case as the file name but was following variable convention and had the png file with an upper case for the second part of the file name. Here my file was putback.png but was referenced in my code as putBack.png
UIImage *putBackImage = [UIImage imageNamed:#"putBack.png"]; //wrong
UIImage *putBackImage = [UIImage imageNamed:#"putback.png"]; //correct
Select correct target while adding image files to your project. Following are steps to make it further clear
Select Add Files to "YourProjectName"
In opening window there is an "Add to targets" option at bottom that shows all available targets
Check target or multiple targets in which you want to add images
Press "Add" button and you are ready to go