Hello
Help please
There is an original image "test.jpg "
We need to reduce it proportionally to a size of 1200 by 1200 pixels, apply a watermark "watermark.png" with a transparency of 60.
Save the result in a new file "result.jpg" with compressingquality=85.
The watermark must be applied to the entire image, it is necessary to adjust the size of the watermark to the size of the image
I got confused in the code:
JPG:=TJPGImage.Create;
IMG:=TImage.Create(Nil);
JPG.LoadFromFile('test.jpg');
if JPG.Width>JPG.Height then
begin
scale:=1200/JPG.Width;
IMG.Height:=round(JPG.Height*scale);
IMG.Width:=1200;
end
else
begin
scale:=1200/JPG.Height;
IMG.Width:=round(JPG.Width*scale);
IMG.Height:=1200;
end;
IMG.Canvas.StretchDraw(rect(0,0,IMG.Width,IMG.Height),JPG);
watermark:=TBGRABitmap.Create('watermark.png');
watermark.Draw(IMG.picture.bitmap.canvas,0,0, false);
IMG.Picture.SaveToFile('rezult.jpg');
jpg.Free;
IMG.Free;
watermark.Free;