-1

fI have the following code:

$ipaFile= '/path/file.ipa';
$iconFilePath = "Payload/myapp.app/AppIcon40x40@2x.png"; // the pathway to my image file    if     the ipa file is unzipped.
$iconFile = "AppIcon40x40@2x.png";
$iconSaveFile = '/path/';

if ($zip->open($ipaFile) === TRUE) {
if($zip->locateName($iconFilePath) !== FALSE) {

    if($iconData = $zip->getFromName($iconFilePath)) {
    file_put_contents($iconSaveFile.$IconFile, $iconData);

    }
}
}

This code successfully pulls an image out of an ipa (zipped) file and puts it where I want it to be. The image displays properly in image viewing programs. However, when I want to view the image in a browser, the browser tells me that the image cannot be displayed because it contains errors.

Doing further research, I get that the file is somehow not being unzipped incorrectly. There are a lot of issues regarding images not displaying in browsers, but there are a wide variety of reasons and I'm just not sure which one is mine. I've tested a variety of ways to try and fix the problem (fread method of getting file, using PHP's image functions, using headers, etc) and I can't seem to make it work. Any help would be appreciated, thanks.

Pete_1
  • 981
  • 3
  • 14
  • 23
  • The answer to this question shows how to properly unzip and save files using php: http://stackoverflow.com/questions/8889025/unzip-a-file-with-php – MrMadsen Dec 19 '14 at 19:56
  • I don't want to use extractTo, as I don't want directories to be extracted as well. This method works just fine with extracting only one specific file from a zipped file. The only problem I have using this is with images. – Pete_1 Dec 19 '14 at 20:04
  • In what way is an image not a file? – GolezTrol Dec 19 '14 at 20:06
  • Right. Other kinds of files are unzipped and display just fine using the above code. Images, however, I am having a problem with when it comes to displaying in a browser afterwards. I have used the Fread method as opposed to copying the file within the zipped archive as I have done above, but I get the same problem. Because of what I am trying to accomplish, I can't use extractTo. – Pete_1 Dec 19 '14 at 20:11
  • 1
    Did you check that the image was zipped correctly? Can you unzip without your code and view the image correctly? – MrMadsen Dec 19 '14 at 20:16
  • I didn't think to test the original file, unzipping it on my OS. The unzipped file also is broken. There must be a problem with the original image and the way it was zipped in the first place. Thanks. – Pete_1 Dec 19 '14 at 20:27

1 Answers1

0

For any who will wonder, when Xcode (Apple) compiles an app, it modifies the PNG files within them and a standard browser will not render them as is.

http://echoone.com/filejuicer/formats/ipa

https://theiphonewiki.com/wiki/IPA_File_Format

Pete_1
  • 981
  • 3
  • 14
  • 23