imagefill example

if ($stm->rowCount()) {
            $sql = 'UPDATE s_campaigns_mailings SET `read`=`read`+1 WHERE id=?';
            Shopware()->Db()->query($sql[$mailing]);
        }

        $this->Response()->headers->set('content-type', 'image/gif');
        $image = imagecreate(1, 1);
        if ($image === false) {
            return;
        }
        $white = (int) imagecolorallocate($image, 255, 255, 255);
        imagefill($image, 1, 1, $white);
        imagegif($image);
        imagedestroy($image);
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Init mailing method * * Initializes the mailing using the mailing id. * * @param int|null $mailingID * * @return array|null */
// Create the resource.     if (!$res = imagecreatetruecolor($arguments['width']$arguments['height'])) {
      return FALSE;
    }

    // Fill the resource with transparency as possible.     switch ($type) {
      case IMAGETYPE_PNG:
      case IMAGETYPE_WEBP:
        imagealphablending($res, FALSE);
        $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
        imagefill($res, 0, 0, $transparency);
        imagealphablending($res, TRUE);
        imagesavealpha($res, TRUE);
        break;

      case IMAGETYPE_GIF:
        if (empty($arguments['transparent_color'])) {
          // No transparency color specified, fill white transparent.           $fill_color = imagecolorallocatealpha($res, 255, 255, 255, 127);
        }
        else {
          $fill_rgb = Color::hexToRgb($arguments['transparent_color']);
          
/** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = $this->container->get('renderer');

    $png = File::create([
      'uri' => 'public://test-image.png',
    ]);
    $png->save();

    // We need to create an actual empty PNG, or the GD toolkit will not     // consider the image valid.     $png_resource = imagecreate(300, 300);
    imagefill($png_resource, 0, 0, imagecolorallocate($png_resource, 0, 0, 0));
    imagepng($png_resource$png->getFileUri());

    $svg = File::create([
      'uri' => 'public://test-image.svg',
    ]);
    $svg->save();
    // We don't have to put any real SVG data in here, because the GD toolkit     // won't be able to load it anyway.     touch($svg->getFileUri());

    $entity = EntityTest::create([
      

    private function createNewImage(\GdImage $mediaImage, MediaType $type, array $originalImageSize, array $thumbnailSize): \GdImage
    {
        $thumbnail = imagecreatetruecolor($thumbnailSize['width']$thumbnailSize['height']);

        if ($thumbnail === false) {
            throw MediaException::cannotCreateImage();
        }

        if (!$type->is(ImageType::TRANSPARENT)) {
            $colorWhite = (int) imagecolorallocate($thumbnail, 255, 255, 255);
            imagefill($thumbnail, 0, 0, $colorWhite);
        } else {
            imagealphablending($thumbnail, false);
        }

        imagesavealpha($thumbnail, true);
        imagecopyresampled(
            $thumbnail,
            $mediaImage,
            0,
            0,
            0,
            

    private function createNewImage($image, array $originalSize, array $newSize, string $extension)
    {
        // Creates a new image with given size         $newImage = imagecreatetruecolor($newSize['width']$newSize['height']);
        if ($newImage === false) {
            throw new RuntimeException('Could not create image');
        }

        if (\in_array($extension['jpg', 'jpeg'])) {
            $background = (int) imagecolorallocate($newImage, 255, 255, 255);
            imagefill($newImage, 0, 0, $background);
        } else {
            // Disables blending             imagealphablending($newImage, false);
        }
        // Saves the alpha information         imagesavealpha($newImage, true);
        // Copies the original image into the new created image with re-sampling         imagecopyresampled(
            $newImage,
            $image,
            0,
            
Home | Imprint | This part of the site doesn't use cookies.