Save The Alpha Channel Information For Png Resource

@param Jaguar\Format\Png $png
@param boolean           $flag true to save false to ignore

@return \Jaguar\Format\Png
@throws \Jaguar\Exception\CanvasException
974530
protected function saveAlpha(Png $png, $flag)
    {
        if ($flag) {
            $png->alphaBlending(false);
            if (false == @imagesavealpha($png->getHandler(), $flag)) {
                throw new CanvasException(sprintf(
                        'Faild Saving The Alpha Channel Information To The Png Canvas "%s"'
                        , (string) $this
                ));
            }
        }

        return $this;
    }
1016853
protected void setFlag(Flag flag, boolean active) {
    if (active) {
      flags |= flag.bitmask;
    } else {
      flags &= ~flag.bitmask;
    }
  }
1085285
public function setActiveOnly($flag = true)
    {
        $flag = (bool)$flag;
        if ($this->activeOnly !== $flag) {
            $this->clear();
            $this->activeOnly = $flag;
        }
        return $this;
    }
738504
final public function option($flag)
    {
        $result = null;

        if (array_key_exists($flag, $this->shellOptions)) {
            $result = $this->shellOptions[$flag];
        }

        return $result;
    }
599406
public function setHollow($flag = true)
    {
        $this->traitSetHollow($flag);

        if ($flag) {
            $this->format = '';
        } else {
            $this->format = $this->formatBack;
        }

        return $this;
    }
1087567
private static function colorBlend($imagickInstance, $color, $alpha = 1, $composite_flag = \Imagick::COMPOSITE_COLORIZE)
    {
        $draw = new \ImagickDraw();
        $draw->setFillColor($color);

        $width = $imagickInstance->getImageWidth();
        $height = $imagickInstance->getImageHeight();

        $draw->rectangle(0, 0, $width, $height);

        $temporary = new \Imagick();
        $temporary->setBackgroundColor(new \ImagickPixel('transparent'));
        $temporary->newImage($width, $height, new \ImagickPixel('transparent'));
        $temporary->setImageFormat('png32');
        $temporary->drawImage($draw);

        if (method_exists($imagickInstance, 'setImageClipMask')) { // ImageMagick < 7
            $alphaChannel = clone $imagickInstance;
            $alphaChannel->setImageAlphaChannel(\Imagick::ALPHACHANNEL_EXTRACT);
            $alphaChannel->negateImage(false, \Imagick::CHANNEL_ALL);
            $imagickInstance->setImageClipMask($alphaChannel);
        } else {
            // need to figure out how to add support for maintaining opacity in ImageMagick 7
        }

        $clone = clone $imagickInstance;
        $clone->compositeImage($temporary, $composite_flag, 0, 0);

        if (method_exists($clone, 'setImageAlpha')) { // ImageMagick >= 7
            $clone->setImageAlpha($alpha);
        } else {
            $clone->setImageOpacity($alpha);
        }
        
        $imagickInstance->compositeImage($clone, \Imagick::COMPOSITE_DEFAULT, 0, 0);
    }
897670
public function withPolicyMappingInhibit(bool $flag): self
    {
        $obj = clone $this;
        $obj->_policyMappingInhibit = $flag;
        return $obj;
    }
1175759
public function withFlag($flag): void
    {
        $flag = $this->parseFlag($flag);

        $this->flags = $this->flags | $flag;
    }
998826
function save() {
		$fw=Base::instance();
		if ($this->flag) {
			if (!is_dir($dir=$fw->get('TEMP')))
				mkdir($dir,Base::MODE,TRUE);
			$this->count++;
			$fw->write($dir.'/'.
				$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
				$fw->hash($this->file).'-'.$this->count.'.png',
				$this->dump());
		}
		return $this;
	}
980705
private function parseFlag($flags, $flag) {
        $flag = strtolower($flag);

        if (property_exists($flags[0], strtoupper($flag))) {
            $this->flags->put($flag, $flags[0]->{strtoupper($flag)});
        } elseif (property_exists($flags[0], ucfirst($flag))) {
            $this->flags->put($flag, $flags[0]->{ucfirst($flag)});
        } elseif (property_exists($flags[0], $flag)) {
            $this->flags->put($flag, $flags[0]->$flag);
        }
    }
1253373
private function isFlagEnabled($flag): bool
    {
        $flag = $this->parseFlag($flag);

        return $flag === ($this->flags & $flag);
    }
339019
public function setDispatched($flag)
    {
        $this->dispatched = $flag ? true : false;

        if ($flag) {
            $this->emitRequestDispatched($this);
        }
    }
796949
public function get($flag)
    {
        if (!array_key_exists($flag, $this->pinputs)) {
            throw new \Exception('Input ' . $flag . ' cannot be found');
        } else {
            return $this->pinputs[$flag];
        }
    }
1114519
public function fileOnly($flag = true)
    {
        $this->file_only = $flag;
        if ($this->file_only) $this->directory_only = false;
        return $this;
    }
526211
public function setProtocol($flag = true) {
        $this->flag = $flag;
        if($flag){
            $this->protocol = 'https';
        }else{
            $this->protocol = 'http';
        }
    }
1036934
protected function saveFile(): AbstractResize
    {
        $result = imagepng(
            $this->canvas['canvas'],
            $this->path . $this->file,
            $this->canvas['quality']
        );

        if ($result === false) {
            throw new \Exception('Unable to save new image');
        }

        return $this;
    }
159829
private function add_flag_to_message($messageid, $flag) {
        // Get the current mailbox.
        $mailbox = $this->get_mailbox();

        // Mark it as read to lock the message.
        $this->client->store($mailbox, array(
            'ids' => new \Horde_Imap_Client_Ids($messageid),
            'add' => $flag,
        ));
    }