load->library('upload', $config); if (!$CI->upload->do_upload($fieldName)) { $CI->form_validation->set_message('_upload_image', $CI->upload->display_errors()); return false; } return true; } function StoreImages($imageType, $filename) { $CI =& get_instance(); $CI->load->library('aws'); $s3 = new AmazonS3(); $imageResolutions = $CI->config->item('image_resolutions'); if(is_array($imageResolutions) && isset($imageResolutions[$imageType])) foreach($imageResolutions[$imageType] as $imageResolutionTypeName => $imageResolutionType) { // Open the file $fullPath = $_SERVER['DOCUMENT_ROOT'] . "/system/application/assets/dropbox/$imageType/$imageResolutionTypeName/$filename"; $handle = fopen($fullPath, "rb"); $contents = fread($handle, filesize($fullPath)); fclose($handle); $contentType = "binary/octet-stream"; $s3Result = $s3->create_object($CI->config->item('s3_path'), array( 'filename' => "$imageType/$imageResolutionTypeName/$filename", 'body' => $contents, 'contentType' => $contentType, 'acl' => S3_ACL_PUBLIC, )); if(!$s3Result->isOK()) return false; } return true; } /* Resizing functions */ function ResizeImages($imageType, $uploadData) { if(isset($_FILES['userfile'])&&is_uploaded_file($_FILES['userfile']['tmp_name'])) { ResizeImagesRoot($imageType, $uploadData['file_name']); } else if(is_uploaded_file($_FILES['videoImage']['tmp_name'])) { ResizeImagesRoot($imageType, $uploadData['file_name']); } } function ResizeImagesToS3($imageType, $filename) { ResizeImagesRoot($imageType, $filename); StoreImages($imageType, $filename); } function ResizeUploadedImagesToS3($imageType, $uploadData) { ResizeImages($imageType, $uploadData); StoreImages($imageType, $uploadData['file_name']); } function ResizeImagesRoot($imageType, $filename) { $CI =& get_instance(); $imageResolutions = $CI->config->item('image_resolutions'); $path = './system/application/assets/dropbox/'; $imageSize = getimagesize($path . 'originals/' . $filename); $imageWidth = $imageSize[0]; $imageHeight = $imageSize[1]; if(is_array($imageResolutions) && isset($imageResolutions[$imageType])) foreach($imageResolutions[$imageType] as $imageResolutionTypeName => $imageResolutionType) { $targetWidth = $imageResolutionType[0]; $targetHeight = $imageResolutionType[1]; $resizeType = isset($imageResolutionType[2]) ? $imageResolutionType[2] : EXACT; $newImageWidth = floor(($targetWidth * $imageHeight) / $targetHeight); $newImageHeight = floor(($imageWidth * $targetHeight) / $targetWidth); $targetImageRatio = $targetWidth / $targetHeight; $newImageRatio = $newImageWidth / $newImageHeight; // EXACT - scale and crop to exact dimensions if($resizeType == EXACT) { if($imageWidth >= $targetWidth && $imageHeight >= $targetHeight) { // resize the full to proper dimensions if($targetImageRatio > $newImageRatio) CreateThumb($path."originals/$filename", $path."originals/working_$filename", 9999, $targetHeight); else CreateThumb($path."originals/$filename", $path."originals/working_$filename", $targetWidth, 9999); // resize to final dimensions CropToCenter($path."originals/working_$filename", $path."$imageType/$imageResolutionTypeName/$filename", $targetWidth, $targetHeight); } else { copy($path."originals/$filename", $path."$imageType/$imageResolutionTypeName/$filename"); } } // WITHIN - resize image to fit within the dimensions given while maintaining proportion if($resizeType == WITHIN) { if($imageWidth > $targetWidth || $imageHeight > $targetHeight) { $resizeHeight = $imageWidth * $targetHeight / $targetWidth; $resizeWidth = $imageHeight * $targetWidth / $targetHeight; $workingWidth = $imageWidth; $workingHeight = $imageHeight; if($workingWidth > $targetWidth) { $workingWidth = $targetWidth; $workingHeight = ($workingWidth * $targetHeight) / $targetWidth; } if($workingHeight > $targetHeight) { $workingHeight = $targetHeight; $workingWidth = ($workingHeight * $targetWidth) / $targetHeight; } // resize to proper dimensions CreateThumb($path."originals/$filename", $path."$imageType/$imageResolutionTypeName/$filename", $workingWidth, $workingHeight); } else { // resize to proper dimensions copy($path."originals/$filename", $path."$imageType/$imageResolutionTypeName/$filename"); } } // HEIGHT - scale height to an exact dimension while ignoring the width parameter // WIDTH - scale width to an exact dimension while ignoring the height parameter } } function CreateThumb($sourceFile, $destFile, $width, $height, $forceEnlarge = false) { $CI =& get_instance(); if(!isset($CI->image_lib)) $CI->load->library('image_lib'); $CI->image_lib->clear(); unset($config); if($sourceFile != $destFile) copy($sourceFile, $destFile); $imageSize = getimagesize($destFile); $imageWidth = $imageSize[0]; $imageHeight = $imageSize[1]; $config['image_library'] = 'gd2'; $config['source_image'] = $destFile; $config['maintain_ratio'] = TRUE; $config['width'] = $width; $config['height'] = $height; $CI->image_lib->initialize($config); $CI->image_lib->resize(); } /* Cropping functions */ function CropImage($workingFile, $targetWidth = false, $targetHeight = false) { $CI =& get_instance(); if(!isset($CI->image_lib)) $CI->load->library('image_lib'); $CI->image_lib->clear(); unset($config); $imageSize = getimagesize($workingFile); $imageWidth = $imageSize[0]; $imageHeight = $imageSize[1]; $config['image_library'] = 'gd2'; $config['source_image'] = $workingFile; $config['maintain_ratio'] = false; if($targetWidth) $config['width'] = $targetWidth - ($imageWidth - $targetWidth); if($targetHeight) $config['height'] = $targetHeight - ($imageHeight - $targetHeight); if($targetWidth) $config['x_axis'] = $imageWidth - $targetWidth; if($targetHeight) $config['y_axis'] = $imageHeight - $targetHeight; if($config['x_axis'] < 0) $config['x_axis'] = 0; if($config['y_axis'] < 0) $config['y_axis'] = 0; $CI->image_lib->initialize($config); if(!$CI->image_lib->crop()) { echo $CI->image_lib->display_errors(); } } function CropImageFromPost() { $CI =& get_instance(); unset($config); // size of picture $targ_w = $CI->input->post('finalWidth'); $targ_h = $CI->input->post('finalHeight'); $src = $CI->input->post('image'); $type = $CI->input->post('imageType'); if($type == 'jpeg' || $type == 'jpg') $img_r = imagecreatefromjpeg($src); if($type == 'png') $img_r = imagecreatefrompng($src); if($type == 'gif') $img_r = imagecreatefromgif($src); $dst_r = ImageCreateTrueColor($targ_w, $targ_h); imagecopyresampled($dst_r,$img_r,0,0,$CI->input->post('x'),$CI->input->post('y'), $targ_w,$targ_h,$CI->input->post('w'),$CI->input->post('h')); if($type == 'jpeg' || $type == 'jpg') imagejpeg($dst_r, $src); if($type == 'png') imagepng($dst_r, $src); if($type == 'gif') imagegif($dst_r, $src); } function CropToCenter($sourceFile, $destFile, $targetWidth, $targetHeight) { if(!file_exists($sourceFile)) return false; $imageSize = getimagesize($sourceFile); $imageWidth = $imageSize[0]; $imageHeight = $imageSize[1]; copy($sourceFile, $destFile); CropImage($destFile, $imageWidth - (($imageWidth - $targetWidth)/2), $imageHeight - (($imageHeight - $targetHeight) / 2)); } /* Rotating functions */ function RotateImage($workingFile, $degrees) { $CI =& get_instance(); if(!isset($CI->image_lib)) $CI->load->library('image_lib'); $CI->image_lib->clear(); unset($config); $config['source_image'] = $workingFile; $config['rotation_angle'] = $degrees; $CI->image_lib->initialize($config); if(!$CI->image_lib->rotate()) { echo $CI->image_lib->display_errors(); } } function GetImageOrientation($sourceFile) { //no image found if(!exif_read_data($sourceFile)) return false; $exif = exif_read_data($sourceFile); //no orientation exif if(!isset($exif['Orientation'])) return false; //correct orientation if($exif['Orientation'] == 1) return true; //rotate these if($exif['Orientation'] == 3 || $exif['Orientation'] == 4) RotateImage($sourceFile, '180'); if($exif['Orientation'] == 6 || $exif['Orientation'] == 5) RotateImage($sourceFile, '270'); if($exif['Orientation'] == 8 || $exif['Orientation'] == 7) RotateImage($sourceFile, '90'); //flip these if(in_array($exif['Orientation'],array(2,4,5,7))) RotateImage($sourceFile, 'hor'); //add exif data to new image //requires PEL library } /* Default Image function */ function DefaultImage($imageType, $imageSubType, $imageFilename = '', $attributes = '') { $CI =& get_instance(); $imageResolutions = $CI->config->item('image_resolutions'); if(!empty($imageFilename)) { $img = ''; } else { $img = ''; } return $img; }

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/rachaelmoore/rachaelmoorephotography.com/httpdocs/system/application/helpers/image_helper.php:328)

Filename: libraries/Session.php

Line Number: 662

Rachael Moore Photography: Photo Gallery : Portraits

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: stylesheetName

Filename: views/application.php

Line Number: 39

" />