KD2 Framework  Check-in [f895c67fd2]

Overview
Comment:Image: Fix issues with compression and Imagick
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 7.3
Files: files | file ages | folders
SHA1: f895c67fd2b289802b923922f7b653c8ed5b36ca
User & Date: bohwaz on 2020-11-13 02:24:51
Other Links: branch diff | manifest | tags
Context
2020-11-15
18:37
Fix division by zero check-in: 7c64e0fb43 user: bohwaz tags: 7.3
2020-11-13
02:24
Image: Fix issues with compression and Imagick check-in: f895c67fd2 user: bohwaz tags: 7.3
02:24
Plot: Improve plot axis check-in: fc76ab5c45 user: bohwaz tags: 7.3
Changes

Modified src/lib/KD2/Graphics/Image.php from [4142789395] to [2975cfdf1b].

274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

		if ($this->path)
		{
			call_user_func([$this, $this->library . '_open']);
		}
		else
		{
			call_user_func([$this, $this->library . '_blob']);
			$this->blob = null;
		}

		if (!$this->pointer)
		{
			throw new \RuntimeException('Invalid image format, couldn\'t be read: ' . $this->path);
		}







|







274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

		if ($this->path)
		{
			call_user_func([$this, $this->library . '_open']);
		}
		else
		{
			call_user_func([$this, $this->library . '_blob'], $this->blob);
			$this->blob = null;
		}

		if (!$this->pointer)
		{
			throw new \RuntimeException('Invalid image format, couldn\'t be read: ' . $this->path);
		}
792
793
794
795
796
797
798

799
800

801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820

821
822

823
824
825
826
827
828
829
830
831
832
833
834

	protected function imagick_save($destination, $format)
	{
		$this->pointer->setImageFormat($format);

		if ($format == 'png')
		{

			$this->pointer->setCompression(\Imagick::COMPRESSION_LZW);
			$this->pointer->setCompressionQuality($this->compression * 10);

		}
		else if ($format == 'jpeg')
		{
			$this->pointer->setCompression(\Imagick::COMPRESSION_JPEG);
			$this->pointer->setCompressionQuality($this->jpeg_quality);
			$this->pointer->setInterlaceScheme($this->progressive_jpeg ? \Imagick::INTERLACE_PLANE : \Imagick::INTERLACE_NO);
		}

		if ($format == 'gif' && $this->pointer->getIteratorIndex() > 0)
			return file_put_contents($destination, $this->pointer->getImagesBlob());
		else
			return $this->pointer->writeImage($destination);
	}

	protected function imagick_output($format, $return)
	{
		$this->pointer->setImageFormat($format);

		if ($format == 'png')
		{

			$this->pointer->setCompression(\Imagick::COMPRESSION_LZW);
			$this->pointer->setCompressionQuality($this->compression * 10);

		}
		else if ($format == 'jpeg')
		{
			$this->pointer->setCompression(\Imagick::COMPRESSION_JPEG);
			$this->pointer->setCompressionQuality($this->jpeg_quality);
			$this->pointer->setInterlaceScheme($this->progressive_jpeg ? \Imagick::INTERLACE_PLANE : \Imagick::INTERLACE_NO);
		}

		if ($format == 'gif' && $this->pointer->getIteratorIndex() > 0)
			$res = $this->pointer->getImagesBlob();
		else
			$res = (string) $this->pointer;







>
|
|
>



|
|















>
|
|
>



|
|







792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838

	protected function imagick_save($destination, $format)
	{
		$this->pointer->setImageFormat($format);

		if ($format == 'png')
		{
			$this->pointer->setOption('png:compression-level', 9);
			$this->pointer->setImageCompression(\Imagick::COMPRESSION_LZW);
			$this->pointer->setImageCompressionQuality($this->compression * 10);
			$this->pointer->stripImage();
		}
		else if ($format == 'jpeg')
		{
			$this->pointer->setImageCompression(\Imagick::COMPRESSION_JPEG);
			$this->pointer->setImageCompressionQuality($this->jpeg_quality);
			$this->pointer->setInterlaceScheme($this->progressive_jpeg ? \Imagick::INTERLACE_PLANE : \Imagick::INTERLACE_NO);
		}

		if ($format == 'gif' && $this->pointer->getIteratorIndex() > 0)
			return file_put_contents($destination, $this->pointer->getImagesBlob());
		else
			return $this->pointer->writeImage($destination);
	}

	protected function imagick_output($format, $return)
	{
		$this->pointer->setImageFormat($format);

		if ($format == 'png')
		{
			$this->pointer->setOption('png:compression-level', 9);
			$this->pointer->setImageCompression(\Imagick::COMPRESSION_LZW);
			$this->pointer->setImageCompressionQuality($this->compression * 10);
			$this->pointer->stripImage();
		}
		else if ($format == 'jpeg')
		{
			$this->pointer->setImageCompression(\Imagick::COMPRESSION_JPEG);
			$this->pointer->setImageCompressionQuality($this->jpeg_quality);
			$this->pointer->setInterlaceScheme($this->progressive_jpeg ? \Imagick::INTERLACE_PLANE : \Imagick::INTERLACE_NO);
		}

		if ($format == 'gif' && $this->pointer->getIteratorIndex() > 0)
			$res = $this->pointer->getImagesBlob();
		else
			$res = (string) $this->pointer;