Aquaresizer doesn't work - php

I'm trying to include the aquaresize script in my theme. I have added it to assets/components/aq_resize.php
And required it in functions.php
require_once( 'assets/components/aq_resize.php' );
However, when I try to echo
aq_resize($img_url,$width);
Nothing is shown on the page, I gave the variables $img_url a url and $width a number
When I make a console.log in assets/components/aq_resize.php I can see the log in my console.
Why doesn't my aq_resizer work?
The aqua resizer code can be found here: https://github.com/syamilmj/Aqua-Resizer/blob/master/aq_resizer.php
To test it I used a random image from google.
<?php
$img_url = 'http://joombig.com/demo-extensions1/images/gallery_slider/Swan_large.jpg';
$width = 300;
echo aq_resize($img_url,$width);
?>

Some common issues that prevent aq_resizer.php working:
Make sure that the original image has dimensions larger than the new dimensions you want to resize to.
Go to your wordpress admin dashboard > Settings > Media, and make sure that your media library folder is simply 'wp_content/uploads'. (If there is no field available to set the folder, then it's already set to 'wp_content/uploads')

I have solved the problem by activating "gd" library for xampp. You simply have to install/activate gd library. Go to php.ini file and check if "extension=gd" starts with ";". If it starts with ";" simply remove it. Otherwise insert a new line extension=gd.

Related

mPDF not showing image in generated PDF instead showing red x symbol and full url for background image

Recently I have moved from my staging server to production server and I don't have access to any of these servers.
Both of these servers are linux.
On the new server while generating the pdf using mPDF with symfony 1.4 framework, images like rupee symbol are not getting displayed instead a small red "x" symbol is getting displayed in pdf.
Also, when I try to give background image to pdf, full image path like "http://example.com/image/rupee-image.jpg" is getting displayed instead of image.
Rupee symbol, other images and background images are working fine on my staging server.
When, I did $mpdf->showImageError(), It's saying "mPDF Image Error: Could not find image file" and pasting the url in browser displays the image perfectly.
Any help will be greatly appreciated.
mPDF is telling you that it's not finding the image.
Without seeing your code it's difficult to hint you on what's wrong.
Still you probably what to try referring to your images using a full path locally.
So instead of reference like http://example.com/image/rupee-image.jpg
use something like /var/www/mysite/image/rupee-image.jpg , same as if checking the image is there using the command line.
HTH
I had similar problem, i fixed it with replacing http:// to https://. Watch out for it.
I fixed it myself... I have created a variable in my template and then replaced that variable with image location from my action class, using $mpdf->WriteHTML(str_replace('rupee_symbol','₹',$html1));
My problem was PHP 7 in this case! I check condition
if (!empty('/images/someimg.png')) {
echo '<img ...';
} else {
echo 'error in PHP 7';
}
Be carefull using it. Version PHP 7.0.19

barcode39 generation in php

I have gone through this link for the barcode generation.
I have downloaded the zip file and tested in my local host. It worked there, after that I have kept the files in my project and checked there. It doesn't work instead it gave me corrupted image as below.
GIF87aP���������,P���������p�قzu���b�a�I���xmZơFÌ,��}r�~���[�pH��(��>V�ie����q����dZΰ�+�����'�=]��n9?^wv�g��W���UƵ���h�8x(h�����GG� I��z�I:�j�y*zY�ij�::[� �Z+p+�J�k�Z�K�k�|��L�)����`N���qt���r���"�P���>�NA<~��]�p��{���!D +Z�ؠ;
Now I've created a sample file in the same location in my project with simple <?php ?> tags and kept the code
include "Barcode39.php";
// set Barcode39 object
$bc = new Barcode39("abc");
// display new barcode
$bc->draw();
again it worked in the sample file which I have kept in the project, but it is not working in the project related file.
Not getting the issue here.
Its perfectly working fine, make sure Barcode39.php in the same location.
As well it required PHP:GD, check again its install or not.
(Include could be issue if you are using any other framework)
I tested and got the below output
You can also use the below code to generate the gif file of barcode and link it anywhere in any page. you will not face any issue related to using html tags.
<?
// include Barcode39 class
include "Barcode39.php";
// set object
$bc = new Barcode39("123-ABC");
// set text size
$bc->barcode_text_size = 5;
// set barcode bar thickness (thick bars)
$bc->barcode_bar_thick = 4;
// set barcode bar thickness (thin bars)
$bc->barcode_bar_thin = 2;
// save barcode GIF file
$bc->draw("barcode1.gif");
?>
and include this file in the src attr of the image tag like
<img src="http://localhost/yourbarcodefilepath" alt="barcode"/>
then it will work

Display images on site from folder outside public_html folder

I am using codeingiter and had a image directory in it. Due to space issue I have shifted the entire directory to new location on same server.
Earlier path was /var/www/html/site_folder/assets/images
New Location is /home/new_site/images
Now when I want to display images on web site its not getting load.
I have tried using the below code
$file = '/home/new_site/images/3.jpg';
header('Content-Type: image/jpeg');
echo "<img src='".readfile($file)."' &glt;";
I have approximately 50 images and I want to load them on my site.
This works on local but not on server. I am using Linux on local and Centos on server.
You are mixing things up. What you want to do is to return the content of the image file, but you return an HTML fragment.
There are multiple solutions you could try:
Create a symbolic link to the new image directory, most things could stay as they are. This migth or might not work depending on your web server configuration.
Change all the references to images from
src="image5.jpg"
to something
src="image.php?name=image5.jpg"
Then you need the script "image.php" which takes the name of the image as a query parameter and then returns the content:
<?php
// take care to make some clever checks here
// otherwise you introduce a security nightmare
$file = '/home/new_site/images/' . htmlspecialchars($_GET["name"]);
header('Content-Type: image/jpeg');
readfile($file);
?>

Rename Image Uploaded With CKFinder

Can I rename an image that is uploaded using CKFinder?
Do you use the PHP version of CKFinder? If so, the following might help.
When uploading files, you can automatically remove spaces, characters with accents, and such. Set "ForceAscii" to "true" in the config.php file:
$config['ForceAscii'] = true;
The code for the "ForceAscii" setting is found starting on line 59 in this file:
ckfinder\core\connector\php\php5\CommandHandler\FileUpload.php
if ($_config->forceAscii()) {
$sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
}
To rename the file as it's uploaded, you could add your own code to the "ForceAscii" code.
To add some Static text to the beginning or the end:
if ($_config->forceAscii()) {
$sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
$sFileName .= "YourTextHere"; // Append your text
$sFileName = "YourTextHere" . $sFileName; // Prepend your text
}
Just before the force ascii code is a string replace, you could add your own version of a string replace if that would meet your goals.
$sFileName = str_replace(array(":", "*", "?", "|", "/"), "_", $sUnsafeFileName);
If the text used for the rename will vary, you'll need to provide a lot more details:
Will the text vary depending on which user is uploading the file?
Will it vary for each image, regardless of who uploads it?
What will determine the actual text that is used (based on username?).
The latest version, 2.1 allows the user to upload multiple files at one time. This could affect the approach you take.
If you provide additional information, I'll see if I can come up with a better answer.
Is this meant to allow the end user to rename their images?
It is possible for the user to rename an image as follows:
When they are looking at the images in the file browser window, they would right click on an image.
"Rename" is one of the options in the context menu.
EDIT: The latest version of CKFinder (2.1) has a config setting that is placed in the config.js file:
config.showContextMenuArrow = true;
this setting allows the user to access the context menu by clicking on an arrow that appears in the corner of the image.
Be Well,
Joe

FPDF error: Missing or incorrect image file

I am using the FPDF library for generating PDF files by PHP. This library is working fine with plain text(i.e PDF files are generating for any text), but this is giving me an error of FPDF error: Missing or incorrect image file:{MY_FILE_PATH} while trying to add an image to my PDF page. Accessed that file path through the browser, then the corresponding image is appearing fine.
My code is:
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Write(10, 'Example image');
$image_path = MY_FILE_PATH; // This variable contains my actual file path
$pdf->Image($image_path, 10, 10, 350, 450);
$pdf->Output();
This code is working perfectly in my localhost and generating the corresponding PDF files even with the images also, but this is not working after moving to the server.
I have tried with these possibilities like:
With absolute and relative paths for the image.
Tried with a local image placed in the same folder.
All image formats like jpg, png and gif also.
Checked the permissions for the image and corresponding folders also.
None of these cases are working for me, stuck with this problem, can anyone help me to slove this issue.
Thanks!
Siva ...
After a long struggle finally I found the reason for this issue which I've already discussed here.
Mainly this problem is due to the 'allow_url_fopen' setting which is not enabled for my server, I've solved this issue by using the CURL. I'm giving the step by step procedure to solve this issue because this may useful for somebody like me to avoid wastage of time(for finding the solution).
1. Create a temporary file in the local system with write permission.
Ex: $fp = #fopen($local_file_path, 'x');
fclose($fp);
2. Get the remote location file contents using CURL and write that to local file
which is created in the previous step.
Ex: $curl = new CurlWrapper($remote_file_path);
$curl->copyToFile($local_file_path);
3. Now send this local file path to FPDF function(image) then the corresponding
PDF will get generate for the file without any issues.
I think this is one method to solve this issue, if anybody knows some other ways then you can post them here so that this question may be useful for somebody.
just add:
allow_url_fopen = ON
on php.ini (create new if not exists) solves the problem.
http://www.solo-technology.com/blog/2010/04/07/quick-fix-for-url-file-access-is-disabled-issues/
anyone can use this code for solve. may be it will work. because sometime some case may be different. in my case i was getting same issue but after use it. i fixed my issue..
$pdf->Image($image_path, 10, 10, 350, 450 ,'');
try to give empty string to 6 parameter of $pdf->Image() function or you can give file extension like ( PNG or JPG). in my case empty string '' was working. because i was cropping image so that image going some time wrong. so after do that my problem gone fixed and i tested with different images.

Categories