Scaling a watermark to fit parent image

后端 未结 1 1164
旧时难觅i
旧时难觅i 2021-02-11 00:33

My photo sizes vary, they are either landscape, portrait or square, and I need to make a watermark the best fit for each photo - so I need to resize just the width of the waterm

1条回答
  •  难免孤独
    2021-02-11 01:14

    This resizes the watermark and copies directly to the image.

    You don't need the existing imagecopy line anymore.

    $success = imagecopyresized($image,                 // Destination image
               $watermark,                              // Source image
               $imageSize[0]/2 - $newWatermarkWidth/2,  // Destination X
               $imageSize[1]/2 - imagesy($watermark)/2, // Destination Y
               0,                                       // Source X
               0,                                       // Source Y
               $newWatermarkWidth,                      // Destination W
               imagesy($watermark),                     // Destination H
               imagesx($watermark),                     // Source W
               imagesy($watermark));                    // Source H
    

    0 讨论(0)
提交回复
热议问题