Beispiel #1
0
 protected function _copyImages()
 {
     $application = $this->getApplication();
     $icons = array($this->_sources_dst . '/res/drawable-mdpi/app_icon.png' => $application->getIcon(48, null, true), $this->_sources_dst . '/res/drawable-mdpi/push_icon.png' => $application->getIcon(24, null, true), $this->_sources_dst . '/res/drawable-hdpi/app_icon.png' => $application->getIcon(72, null, true), $this->_sources_dst . '/res/drawable-hdpi/push_icon.png' => $application->getIcon(36, null, true), $this->_sources_dst . '/res/drawable-xhdpi/app_icon.png' => $application->getIcon(96, null, true), $this->_sources_dst . '/res/drawable-xhdpi/push_icon.png' => $application->getIcon(48, null, true), $this->_sources_dst . '/res/drawable-xxhdpi/app_icon.png' => $application->getIcon(144, null, true), $this->_sources_dst . '/res/drawable-xxhdpi/push_icon.png' => $application->getIcon(72, null, true), $this->_dst . '/app_icon.png' => $application->getIcon(512, null, true));
     $startup_images = array("mdpi" => array("old" => "startup_image.png", "new" => $application->getStartupImageUrl("standard", "base")), "hdpi" => array("old" => "startup_image.png", "new" => $application->getStartupImageUrl("standard", "base")), "xhdpi" => array("old" => "startup_image.jpg", "new" => $application->getStartupImageUrl("iphone_6", "base")), "xxhdpi" => array("old" => "startup_image.jpg", "new" => $application->getStartupImageUrl("iphone_6_plus", "base")));
     foreach ($startup_images as $density => $startup_image) {
         $oldfile = $startup_image['old'];
         unlink($this->_sources_dst . "/res/drawable-{$density}/{$oldfile}");
         $newfile = $startup_image['new'];
         $extension = pathinfo($newfile, PATHINFO_EXTENSION);
         $icons[$this->_sources_dst . "/res/drawable-{$density}/startup_image.{$extension}"] = $newfile;
     }
     foreach ($icons as $icon_dst => $icon_src) {
         if (Core_Model_Lib_Image::getMimeType($icon_src) != 'image/png') {
             list($width, $height) = getimagesize($icon_src);
             $newStartupImage = imagecreatetruecolor($width, $height);
             $startupSrc = imagecreatefromstring(file_get_contents($icon_src));
             imagecopyresized($newStartupImage, $startupSrc, 0, 0, 0, 0, $width, $height, $width, $height);
             imagepng($newStartupImage, $icon_dst);
         } else {
             if (!@copy($icon_src, $icon_dst)) {
                 throw new Exception($this->_('An error occured while copying your app icon. Please check the icon, try to send it again and try again.'));
             }
         }
     }
     return $this;
 }
Beispiel #2
0
 protected function _copyImages()
 {
     $application = $this->getApplication();
     // Touch Icon
     $icons = array($this->_dst . '/Images.xcassets/AppIcon.appiconset/29x29.png' => $application->getIcon(29, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/29x29-1.png' => $application->getIcon(29, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/29x29@2x.png' => $application->getIcon(58, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/29x29@2x-1.png' => $application->getIcon(58, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/29x29@3x.png' => $application->getIcon(87, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/40x40.png' => $application->getIcon(40, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/40x40@2x.png' => $application->getIcon(80, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/40x40@2x-1.png' => $application->getIcon(80, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/40x40@3x.png' => $application->getIcon(120, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/50x50.png' => $application->getIcon(50, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/50x50@2x.png' => $application->getIcon(100, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/72x72.png' => $application->getIcon(72, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/72x72@2x.png' => $application->getIcon(144, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/76x76.png' => $application->getIcon(76, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/76x76@2x.png' => $application->getIcon(152, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/57x57.png' => $application->getIcon(57, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/57x57@2x.png' => $application->getIcon(114, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/60x60@2x.png' => $application->getIcon(120, null, true), $this->_dst . '/Images.xcassets/AppIcon.appiconset/60x60@3x.png' => $application->getIcon(180, null, true), $this->_dst . '/../TouchIcon.png' => $application->getAppStoreIcon(true));
     foreach ($icons as $icon_dst => $icon_src) {
         if (!@copy($icon_src, $icon_dst)) {
             throw new Exception($this->_('An error occured while copying your app icon. Please check the icon, try to send it again and try again.'));
         }
     }
     // Startup Images
     $startup_src = $application->getStartupImageUrl("standard", true);
     $startup_src_retina = $application->getStartupImageUrl("retina", true);
     $startup_src_iphone_6 = $application->getStartupImageUrl("iphone_6", true);
     $startup_src_iphone_6_plus = $application->getStartupImageUrl("iphone_6_plus", true);
     $startup_src_ipad_retina = $application->getStartupImageUrl("ipad_retina", true);
     $startups = array($startup_src => array(array("width" => 320, "height" => 480, "dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/320x480.png'), array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/640x960.png'), array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/640x960-1.png')), $startup_src_retina => array(array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/640x1136.png'), array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/640x1136-1.png')), $startup_src_iphone_6 => array(array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/750x1334.png')), $startup_src_iphone_6_plus => array(array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/1242x2208.png')), $startup_src_ipad_retina => array(array("width" => 768, "height" => 1024, "dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/768x1024.png'), array("width" => 768, "height" => 1024, "dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/768x1024-1.png'), array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/1536x2048.png'), array("dst" => $this->_dst . '/Images.xcassets/LaunchImage.launchimage/1536x2048-1.png')));
     try {
         foreach ($startups as $startup_src => $images) {
             foreach ($images as $image) {
                 if (!empty($image["width"]) or Core_Model_Lib_Image::getMimeType($startup_src) != 'image/png') {
                     list($width, $height) = getimagesize($startup_src);
                     if (empty($image["width"])) {
                         $image["width"] = $width;
                     }
                     if (empty($image["height"])) {
                         $image["height"] = $height;
                     }
                     $newStartupImage = imagecreatetruecolor($image["width"], $image["height"]);
                     $startupSrc = imagecreatefromstring(file_get_contents($startup_src));
                     imagecopyresized($newStartupImage, $startupSrc, 0, 0, 0, 0, $image["width"], $image["height"], $width, $height);
                     imagepng($newStartupImage, $image["dst"]);
                 } else {
                     if (!@copy($startup_src, $image["dst"])) {
                         throw new Exception('An error occurred while generating the startup image. Please check the image, try to send it again and try again.', "{$image["width"]}x{$image["height"]}");
                     }
                 }
             }
         }
     } catch (Exception $e) {
         throw new Exception('An error occurred while generating the startup image. Please check the image, try to send it again and try again.');
     }
 }