/** * Function that gets called on a job * Push::queue('smsSender', $emergency); * * @param $job * @param Emergency $emergency */ public function fire($job, $image) { $s3 = AWS::get('s3'); $image = Image::find($image['id']); if (!$image) { return $job->delete(); } try { $imageUtil = new ImageUtil($image->origin); $galleryImageUtil = new ImageUtil($image->origin); } catch (Exception $e) { return $job->delete(); } $image->thumbnail = $this->uploadImage($s3, $imageUtil->resize2('thumbnail')->getImage()); Log::debug("From queue: Thumbnail: width - {$imageUtil->getWidth()}, height - {$imageUtil->getHeight()}"); Log::debug("Thumbnail URL: {$image->thumbnail}"); $this->preventMemoryLeak(); $image->regular = $this->uploadImage($s3, $galleryImageUtil->resize2('gallery')->getImage()); Log::debug("From queue: Gallery: width - {$galleryImageUtil->getWidth()}, height - {$galleryImageUtil->getHeight()}"); Log::debug("Gallery URL: {$image->regular}"); $this->preventMemoryLeak(); $image->width = $galleryImageUtil->getWidth(); $image->height = $galleryImageUtil->getHeight(); $image->save(); return $job->delete(); }
public function upload() { if (!Input::hasFile('image')) { return $this->respondNotFound('Image not found'); } $this->log('Started'); $this->log(memory_get_usage(true)); $attachment = new Image(); $this->file = Input::file('image'); $this->log('Init origin image'); $image = new ImageUtil($this->file); $this->log(memory_get_usage(true)); $this->log('Uploading origin image'); $this->log(memory_get_usage(true)); $attachment->origin = $this->uploadImage2($image->getImage()); $this->log(memory_get_usage(true)); // preventMemoryLeak(); $this->log('Garbage collector'); $this->log(memory_get_usage(true)); $this->log('Gallery image upload'); $attachment->regular = $this->uploadImage2($image->resize2('gallery')->getImage()); $this->log(memory_get_usage(true)); $this->log('Destroying gallery image'); $image->getImage()->destroy(); $image = null; $this->log(memory_get_usage(true)); // preventMemoryLeak(); $this->log('Garbage collector'); $this->log(memory_get_usage(true)); $this->log('Init thumbnail image'); $thumb = new ImageUtil($this->file); $thumb->resize2('thumbnail'); $this->log(memory_get_usage(true)); $this->log('uploading thumbnail image'); $attachment->thumbnail = $this->uploadImage2($thumb->getImage()); $this->log(memory_get_usage(true)); // preventMemoryLeak(); $this->log('Garbage collector'); $this->log(memory_get_usage(true)); $attachment->width = $thumb->getWidth(); $attachment->height = $thumb->getHeight(); $this->log('Destroying the thumb image'); $thumb->getImage()->destroy(); $thumb = null; $this->log(memory_get_usage(true)); $attachment->save(); return $this->respond($this->collectionTransformer->transformImage($attachment)); }