Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-10-2022, 11:48 AM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
Imagemagick Question

This code is working fine, however, when I right click on the image to save it, it doesnt have a .jpg extension, any idea why?

I have the header and extension in the code which should be enough to render it as a .jpg shouldnt it?

Quote:
<?php
/* Create some objects */
$image = new Imagick();
$draw = new ImagickDraw();
$draw1 = new ImagickDraw();
$draw2 = new ImagickDraw();
$draw3 = new ImagickDraw();
$draw4 = new ImagickDraw();
$pixel = new ImagickPixel( '#0076a3' );

/* New image */
$image->newImage(2000, 3000, $pixel);

$rect = [
'x' => 175,
'y' => 1850,
'h' => 1000,
'w' => 1650,
];

// Draw a Region-of-interest for reference.
$roi = new ImagickDraw();
$roi->setFillColor('#292b2a');
$roi->rectangle($rect['x'],
$rect['y'],
$rect['x'] + $rect['w'],
$rect['y'] + $rect['h']);
$image->drawImage($roi);

$rect = [
'x' => 0,
'y' => 0,
'h' => 75,
'w' => 2000,
];

// Draw a Region-of-interest for reference.
$roi = new ImagickDraw();
$roi->setFillColor('#292b2a');
$roi->rectangle($rect['x'],
$rect['y'],
$rect['x'] + $rect['w'],
$rect['y'] + $rect['h']);
$image->drawImage($roi);

/* Text Color */
$draw->setFillColor('#FFFFFF');

/* Font properties */
$draw->setFont('Bookman-DemiItalic');
$draw->setFontSize( 110 );

/* Text Color */
$draw1->setFillColor('#0076a3');

/* Font properties */
$draw1->setFont('Bookman-DemiItalic');
$draw1->setFontSize( 200 );

/* Text Color */
$draw2->setFillColor('#FFFFFF');

/* Font properties */
$draw2->setFont('Bookman-DemiItalic');
$draw2->setFontSize( 75 );

/* Text Color */
$draw3->setFillColor('#FFFFFF');

/* Font properties */
$draw3->setFont('Bookman-DemiItalic');
$draw3->setFontSize( 75 );

/* Text Color */
$draw4->setFillColor('#0076a3');

/* Font properties */
$draw4->setFont('Bookman-DemiItalic');
$draw4->setFontSize( 60 );

/* Create text */
$image->annotateImage($draw, 220, 2050, 0,
'Text');

/* Create text */
$image->annotateImage($draw1, 370, 2250, 0,
'Text');

/* Create text */
$image->annotateImage($draw2, 225, 2375, 0,
'Text');

/* Create text */
$image->annotateImage($draw3, 600, 2475, 0,
'Text');

/* Create text */
$image->annotateImage($draw4, 575, 2750, 0,
'Text');

/* Give image a format */
$image->setImageFormat('jpg');

/* Output the image with headers */
header('Content-type: image/jpg');
echo $image;?>
Also, im trying to overlay an image on top of the main body, I have tried the code below but it does not seem to be working, is there a better way of achieving it?

Quote:
/* Overlay image */
$image->readImage('watermark.png'), 2000, 1500, 0,
$image->setImageAlpha(0.5);
$image->compositeImage($wm, Imagick::COMPOSITE_OVER, 0, 0);
$image->writeImage('final.jpg');
Thanks for any assistance or pointers you can give
__________________
NOTHING TO SEE HERE
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-10-2022, 12:29 PM   #2
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
try

header('Content-Disposition: attachment; filename="whatever.jpg"');
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-10-2022, 01:17 PM   #3
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
Doing a church sign generator? I used to love those.

I can't test the code since it uses "imagick", some php extension, but unless there's a reason you have to use that, look into PHP's "imagecreate" function.

And unless you have to use PHP, you can do this kind of stuff with just Javascript and canvas.

Edit: I bothered to RTFM on the "Imagick" github when I was about to close the tab and it's in the Debian repo, so I tried it. Right clicking and saving in Firefox provides the extension, though it's .jpeg, not .jpg, ie "page.php.jpeg".
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-10-2022, 02:56 PM   #4
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
Quote:
Originally Posted by k0nr4d View Post
try

header('Content-Disposition: attachment; filename="whatever.jpg"');
Awesome, that worked perfectly, thanks man

Any idea about the image overlay / watermark thing?

*edit* How do I stop the whatever.jpg auto downloading on page load?
__________________
NOTHING TO SEE HERE
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-10-2022, 03:08 PM   #5
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
Quote:
Originally Posted by ZTT View Post
Doing a church sign generator? I used to love those.
eBook cover generator, hoping itll save my guys some time when it comes to processing new title covers

Just have to figure out why the image overlay stuff isnt working lol
__________________
NOTHING TO SEE HERE
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-10-2022, 10:57 PM   #6
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,116
One more issue I just discovered...

Quote:
/* Font properties */
$draw4->setFont('Bookman-DemiItalic');
$draw4->setFontSize( 60 );
$draw4->setGravity(Imagick::GRAVITY_CENTER );
Isn't centering the text, any clues as to why?
__________________
NOTHING TO SEE HERE
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-11-2022, 01:05 AM   #7
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Quote:
Originally Posted by Publisher Bucks View Post
Awesome, that worked perfectly, thanks man

Any idea about the image overlay / watermark thing?

*edit* How do I stop the whatever.jpg auto downloading on page load?
I've honestly never used imagemagick from php like that, only from command line.
What about a rewriterule so the image URL ends in .jpg?
line1|line2|line3.jpg or something.
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
image, code, overlay, .jpg, extension, achieving, assistance, pointers, $image-compositeimage$wm, $image-setimagealpha0.5;, imagickcomposite_over, save, idea, header, click, question, fine, top, main, imagemagick, render, body



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.