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 #219709 by tgribble
php imagecreatefromjpeg() in article was created by tgribble
hello

i was hoping someone with php skills could solve this for me? i know its more a joomla not a cb question, but hopefully it is a simple code?

in php i can easily make membership card using the following:
Code:
<?php //Set the Content Type header('Content-type: image/jpeg'); // Create Image From Existing File $jpg_image = imagecreatefromjpeg('membershipcard.jpeg'); // 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 CARS 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); ?>


where the membership card image is written over by the test text to produce an image that is printable. but of course i would like to be able to do this within a joomla article so as to put cb data in the membership card from the database(s)

the issue is getting the
Code:
$jpg_image = imagecreatefromjpeg('membershipcard.jpeg');

line to get the image from the server ( and the same with the font )

how do i make this happen? i have the sourcerer plugin to be able to use php in an article.

any ideas? i am new to php so sorry if it a basic question.

thankyou

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 #219767 by krileon
Replied by krileon on topic php imagecreatefromjpeg() in article
You probably just need to supply the absolute or live path to your files. I've no idea how sourcerer works so I've no idea what API is available to you. If it's a hardcoded path then just manually add the path, example as follows.

/username/htdocs/images/membershipcard.jpeg

If you've access to Joomla API you can try the below.

imagecreatefromjpeg(JPATH_BASE.'/membershipcard.jpeg');

Please note we don't help with this sort of thing; especially when it has no relation to CB at all and I highly suggest contacting a contract developer to help create this for you or further researching PHP usage and Joomla API.


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 - 11 years 9 months ago #219825 by tgribble
Replied by tgribble on topic php imagecreatefromjpeg() in article
thanks krileon for the hint. it is just what i needed. i appreciate it

ultimately it will be cb related as i hope to integrate cb subs data into the image created.

thanks very much anyway. :)
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 #219864 by krileon
Replied by krileon on topic php imagecreatefromjpeg() in article
For CBSubs data look into the plans image field (CBSubs 3.x is no longer encoded) on how to retrieve a users active subscriptions. This will help in populating your image(s) with a users CBSubs information.


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 #219916 by tgribble
Replied by tgribble on topic php imagecreatefromjpeg() in article
thanks again for the reply.
im uncertain if that will be a solution for me, but thanks anyway:

what im trying to do is get ( with imagecreatefromjpeg() ) the image from the server, then each user will be able to go to an article where the image will be displayed and see their own personalised membership card with data from the cbsubs made into the produced image ( using imagettftext() and imagejpeg() )

the reason for this is simply using a background image and text on top , it often cannot pring properly, and i cant seem to imagine another way ? ( unless you have some cool ideas )

thanks again for all the help , i really appreciate it !!

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 #219946 by krileon
Replied by krileon on topic php imagecreatefromjpeg() in article
The image generates on page load, so every page load it should be accurate. You'd need to in PHP grab their CBSubs data and add it to the image in the same way you're adding $text1 and $text2.


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