how to convert text to image in wordpress and create thumbnail - php

hi i have a wordpress at lesprenoms.quebec it's listing the name of people with a short description.
if you take a look at this post:
http://lesprenoms.quebec/qeZN30e9
it's a simple div with image as background with text on top and an other image at the bottom what i want is that wordpress generate all the thumbnail i want and also the one for facebook witch is 750*394px crop top when i hit publish or like save the draft and else and that it get update if i change the text on top of the image.
some will tell me to do this trough photoshop and else witch i already did for the 170 other image but i think i can made template, then just upload the image and just add my text that all trough the website without having to fire photoshop witch can be really usefull as if i'm on other computer and else...
so i know there a way to do this in php with maybe imagefttext or something like that. All the thing is wrap in a div so maybe a function that get all the text + image between the first and the last could be really nice and neat.
so if someone can help cause i really need your help guy...

Related

How to make an image selector for specific content

When creating a new page I want to select an image from a gallery of all images previously uploaded. I've tried searching for a solution for a few hours but can't seem to find any good answers. I already know how to upload and display the images to a gallery from the database.
What I don't know is how to make it so you can select an image and assign it to that page/content.
It's not something that happens automatically. You have to code it.
The algorithm would look something like this:
Display thumbnails with the url/id of the full size picture (see Creating a thumbnail from an uploaded image);
On click, add the url of the picture you want to use on that page.

Cut image after load is complete

I Googled a lot but no sufficient ans was found.
I need to place an image (900 X 5200 px) in one of my pages. As the image is sensitive, I need to prevent users from copying the image. I have an idea that can do this:
I will divide the image into pieces. Then the image grid will be loaded into some divs. So user won't be able to save the image. Or he/she will save only 1 square cm part of the whole image.
But this plan will not work if some small parts of the grid fails to load. So, I want to do another thing. I want to load the full image then cut the image into parts. Then show the parts altogether in divs.
This requires javascript. But I am confused how to start and need your help.
Now you know the matter, if you have better idea please share.
Thanks in advance.
The trick is simple. Create a div with the background being the image you want to display. Layer a div with a transparent image over it. When user goes to save the image, they get a blank. Program your server to not return "direct" requests for the image (so some clever chap can't just look at the css and retrieve the URL to the image).
Granted the image will still be in their cache but so would the sliced image so it won't make it impossible just more difficult for a determined person to retrieve the picture.
TL;DR Don't over engineer a solution, print screen will get around anything you do.
You are not going to be able to prevent people from copying this image. Plain and simple. Regardless of your best efforts, a simple PRT SCRN and paste into Paint will be enough.
Your best bet will be to not over engineer this and simply place a watermark and copyright notice on the page. Other options can include placing a transparent <div> over the top of the image so it cannot be right-click'ed and saved, but it still will not prevent the image from being stored in the user's cache. Or stop them from using developer tools or Firebug to find the source image.
You can do this with:
http://www.pixastic.com/lib/docs/actions/crop/
Yet you need to develop your logic around that library.
I have made example, you can see it on this link:
http://simplestudio.rs/yard/crop_img/
Basically you can get URL to your image via php and using my code or code similar to it crop your image into pieces and display them on canvas.
This way image is not accessible via browser or inspect element or what so ever. User can save the pieces individually but you can configure my code for piece to be 5px, I set it to 20x20px.
* test saving image piece by doing right click anywhere on image and do a "Save image as.." option.
Also you need to think of way how to hide src to image provided by php, if you need help on that I can help you.

Automated image update with page statistics

Frankly I am not sure where this would go but I assume the way to create what I'm about to describe is PHP... so I'm sorry if it's in the wrong section.
Basically I have a website, using Wordpress, where users can review websites and post a 5 star rating of the site. Each reviewed website has it's own dedicated page.
So what I want to do is create an image from the statistics of the ratings to allow the website owners to place it on their page. The image will need to, when clicked, go to that it's review page.
So the image would be about 150x150. Have the overall 5 Star Rating, the Name of the Reviewed site and the name of my website. It would also be cool if there was some automatically generated HTML embedding code so the site owners can simply copy and paste it.
I hope I explained myself ok. I've tried searching google but I'm not entirely sure what to search for and therefore have found nothing useful.
Thanks.
EDIT
I can create the embed code manually. I just need to really know about how to make the picture update automatically.
Hey what you are asking for is quite complex and it would be to easy to just give you code. So here is some reading for you. Your problem is quite meaty and no doubt you'll learn loads sorting it out....
http://www.phptutorial.info/learn/create_images/
http://www.qualitycodes.com/tutorial.php?articleid=20&title=How-to-create-bar-graph-in-PHP-with-dynamic-scaling
I just need to really know about how
to make the picture update
automatically.
Just put URL to your php-script, which will generate image.
You will need function imagettftext to write text over the image, imagecopy to draw the stars (of votes).
Also, you will need image of a star and background.
So, approx. algorithm will be:
1. Open the background image by imagecreatefrompng - it will be our generated image
2. Open the Star image
3. Write title of the reviewed site by imagetttftext
4. Draw stars by copying existing Star image to our background image (by imagecopy)
5. Print generated image by imagepng

how to save image after customization

some of the script like t-shirt design script,mug designer available for customization. For an example. we add text, rotate text, change color of text add/upload image re-size image etc after customization they give image as we customize.
how to save this all customization as image ?
any this type of script in php available ?
I'm guessing what you want is to take modifications made by JavaScript to an image in a browser and "save them" to a new image using PHP?
I am not sure how you'd go about doing that without regenerating the whole thing in PHP.
If I had to do it, I'd save all the modifications in an array in Javascript and using jQuery/AJAX send a request to the PHP file along with those modifications and have the PHP script re-do the things, for example write text on the source image, re-size it, add shapes and what-not.
However, this might end up being quite a time consuming task.

How to embed a text link in an image?

How do I embed text in an image? The embedded text should be hyperlinked to an URL. The use case is like having an image with a link that says 'Click here' which opens a new page.
If you want to stay away from z-indexes and/or image maps, you could do it the old school way, which is to set the image as a background for a table or div, and then just put text inside the table or div.
You have to options to accomplish this:
Add your text to the image with your graphics program of choice. (Use ImageMagick for automated processing) Then create an image map to make parts of the image clickable. If you need some kind of "hot state", then you have to use small images which are absolutely positioned above the original image and show/hide them using Javascript. Depending on your needs it might be easier to make the whole image clickable.
Add a normal image and a normal hyperlink. You can use a regular img tag or use set the background image of the container. Then use absolute positioning to move the hyperlink to the desired position on top of the picture. With that solution you don't need Javascript to create a hover effect.
Using an image editor add the desired text to image itself and then use the image map to the area where text appears to required URL. For a sample please check my sample at http://shreedhar.kotekar.com/ImageMapSample.htm
If you are using asp.net this Embed text in Image using ASP.NET from developer's fusin shows a good example.
Edit- From your comments I see you're looking for php: Adding text to images with PHP
You could use this tool:
http://www.jsclasses.org/package/324-JavaScript-Embed-encoded-text-in-images-using-steganography.html
and here on github:
https://github.com/blauharley/LoremImageCryptonator
With help of this JS-Object you can embed any text you want. It offers two methods (getCryptoImage, getTextFromCryptoImage) that can be used for inserting and extracting any text into and out of an image.
For your use-case you can insert an URL and extract it as soon as the image is clicked.
But first of all you need to create a "Crypto-Image" that a URL has been inserted into before then saves the image. The saved "Crypto-Image" can then be shown on a page.
Hope this helps.

Categories