Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

php imagecreatefromjpeg() in article

  • tgribble
  • tgribble
  • OFFLINE
  • Posts: 71
  • Thanks: 0
  • Karma: 1
11 years 9 months ago - 11 years 9 months ago #219959 by tgribble
Replied by tgribble on topic php imagecreatefromjpeg() in article
thankyou

this is looking promising

i have tried the whole code and it didnt work. are you able to give me some hints as to how to introduce the PHP to the plan image field? DO you do it via the source button on the editor?
Which parts of this code are / are not required?
Code:
<!--?php //Set the Content Type header('Content-type: image/jpeg'); // Create Image From Existing File $jpg_image = imagecreatefromjpeg(membershipcard.jpg'); // Allocate A Color For The Text $white = imagecolorallocate($jpg_image, 255, 255, 255); $black = imagecolorallocate($jpg_image, 0, 0, 0); // Set Path to Font File $font_path = 'swiss.ttf'; $fontsize = 8; // Set Text to Be Printed On Image $text1 = "Test HKPA membership card"; $text2 = "TEST HKPA MEMBERSHIP CARD TWO"; // Print Text On Image size, angle, left offset 0=left, vert offset 0=top imagettftext($jpg_image, $fontsize, 0, 10, 20, $black, $font_path, $text1); imagettftext($jpg_image, $fontsize, 0, 10, 30, $black, $font_path, $text2); // Send Image to Browser imagejpeg($jpg_image); // Clear Memory imagedestroy($jpg_image); ?>

thanks again for all the help
Last edit: 11 years 9 months ago by tgribble.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
11 years 9 months ago #219964 by krileon
Replied by krileon on topic php imagecreatefromjpeg() in article
You need to review the plans image field to see how it pulls a users active subscriptions. You can then use that plan information to add to the image. A database query would probably work fine too depending on what you need.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • tgribble
  • tgribble
  • OFFLINE
  • Posts: 71
  • Thanks: 0
  • Karma: 1
11 years 9 months ago #219970 by tgribble
Replied by tgribble on topic php imagecreatefromjpeg() in article
i just had a read of the cbsubs 3.0 manual and got no further with it.

how cann i write information onto the image in php as you have suggested. the membershipcard.jpg image is displaying fine, but i cant figure out how to get the
Code:
imagettftext($jpg_image, $fontsize, 0, 10, 20, $black, $font_path, $text1); imagettftext($jpg_image, $fontsize, 0, 10, 30, $black, $font_path, $text2);
part to integrate into the image on using the editor?

nearly there, please help....

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #220024 by krileon
Replied by krileon on topic php imagecreatefromjpeg() in article
You're already using the appropriate function to add text to the image. If it's not showing up then you probably have the coordinates wrong, the font path is incorrect, or maybe the other variables are invalid, but that's the right function.

As for grabbing a users active subscriptions the below will do just that.
Code:
$subscriptions = cbpaidSomethingMgr::getAllSomethingOfUser( $user ); if ( $subscriptions ) foreach ( $subscriptions as $type ) { foreach ( array_keys( $type ) as $typeId ) { $subscription = $type[$typeId]; $plan = $subscription->getPlan(); } }

For this to work you need to have CB API available and prepare a CB user object. Both of which are explained in the below tutorials.

www.allmysocials.com/directory/tutorials/item/231-include-api-externally
www.allmysocials.com/directory/tutorials/item/232-establishing-user-object


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • tgribble
  • tgribble
  • OFFLINE
  • Posts: 71
  • Thanks: 0
  • Karma: 1
11 years 8 months ago - 11 years 8 months ago #220286 by tgribble
Replied by tgribble on topic php imagecreatefromjpeg() in article
i have just tried some changes to the code, but it doesnt work still:
Code:
<?php //Set the Content Type header('Content-type: image/jpeg'); // Create Image From Existing File $jpg_path = JURI::Root().'images/membershipcard.jpeg'; echo $jpg_path ; // THIS RETURNS http://xxxx.net/images/membershipcard.jpeg echo '</p>'; $jpg_image = imagecreatefromjpeg($jpg_path); // Allocate A Color For The Text $white = imagecolorallocate($jpg_image, 255, 255, 255); $black = imagecolorallocate($jpg_image, 0, 0, 0); // Set Path to Font File $font_path = JURI::Root().'images/swiss.ttf'; $font_size = 8; echo $font_path ; // THIS RETURNS http://xxxx.net/images/swiss.ttf echo '</p>'; // Set Text to Be Printed On Image $text1 = "Test membership card"; $text2 = "TEST MEMBERSHIP CARD TWO"; // Print Text On Image size, angle, left offset 0=left, vert offset 0=top imagettftext($jpg_image, $font_size, 0, 10, 20, $black, $font_path, $text1); imagettftext($jpg_image, $font_size, 0, 10, 30, $black, $font_path, $text2); // Send Image to Browser imagejpeg($jpg_image); // Clear Memory imagedestroy($jpg_image); ?>

do you think the font path and the image path correct? the echo'ed out info seems correct? any other ideas?
Last edit: 11 years 8 months ago by tgribble.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #220310 by krileon
Replied by krileon on topic php imagecreatefromjpeg() in article
I suggest reviewing the below in CB Captcha to see how we generate PHP GD images.

components/com_comprofiler/plugin/user/plug_cbcaptcha/captchasecurityimages.php


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum