I am using Codeigniter's image_lib library to resize my images, it is working fine but it renames the image as "original_name_thumb.ext". I dont want it to rename it by adding _thumb. I am saving them in new folders. So rename is not required.
just set thumb_marker = "";
$config["thumb_marker"] = "";
while setting config for image library and it should work fine. See docs
Related
What is the correct way to upload,update and get an image or file in laravel ? I had gone through laravel docs and other references but its confusing.Can anyone show a complete simple example for
any disk configuration in filesystems.php
a simple method to upload and update image in controller
and what will be the image full url?
input type file name is image you can store directly into images folder
return $path = $request->image->store('images');
There is a simple two-column table on a website: product name and product image. It's very easy to render in HTML.
The task would be creating an Xlsx file with these columns.
The images are not stored locally but all of them are remote images with full URL.
The export contains ~100-200 rows.
I tried to create a resource with imagecreatefromjpeg and adding it with MemoryDrawing but it took a huge amount of resources.
I tried with Html helper's toRichTextObject and a simple tag but got empty result.
How is it possible to add a remote image to a PhpSpreadsheet cell? It doesn't need working offline, it's fine to load the remote images when the file is opened.
As #FabriceFabiyi mentionned in his comment, and after reading:
PhpSpreadseet documentation on drawing.
PHP documentation on file_get_contents.
PHP documentation on file_set_contents.
This worked for me:
$image = file_get_contents('https://website.com/path/to/image');
$imageName = 'a_nice_image_name';
//You can save the image wherever you want
//I would highly recommand using a temporary directory
$temp_image=tempnam(sys_get_temp_dir(), $imageName);
file_put_contents($temp_image, $image);
// And then PhpSpreadsheet acts just like it would do with a local image
$drawing->setPath($temp_image);
$drawing->setHeight(36);
$drawing->setWorksheet($sheet);
$drawing->setCoordinates('B15');
More on temporary directories in the PHP docs:
sys_get_temp_dir()
tempnam()
There is an example how add image to your excel export:
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
$drawing->setName('Paid');
$drawing->setDescription('Paid');
$drawing->setPath('/images/image-1.png'); // put your path and image here
$drawing->setHeight(30);
$drawing->setCoordinates('A5');
$drawing->setOffsetX(110);
$drawing->setRotation(25);
$drawing->getShadow()->setVisible(true);
$drawing->getShadow()->setDirection(45);
$drawing->setWorksheet($spreadsheet->getActiveSheet());
Specifying coordinates for the image might help, as per the examples and the documentation
$objDrawing->setCoordinates('A3');
Note that an image isn't in a cell/column/row, but overlaid over the main sheet at the same position as that cell/column/row
I'm trying to resize my images using Intervention package in my laravel project. I'm able to store images using Storage facade, but when I store them with Image class it throws below error.
Can't write image data to path
(/var/www/commerce/storage/featureds/2-1537128615.jpg)
if ($request->has("featured_img")) {
$file_path = $request->get("featured_img");
$exp = explode("/",$file_path);
$filename = $exp[1];
$featured_path = "featureds/".$filename;
\Storage::copy($request->get("featured_img"), $featured_path);
\Image::make(\Storage::get($featured_path))->fit(400, 300)->save(storage_path($featured_path));
$product->media()->where("type", "featured")->update(["path" => $featured_path]);
}
How can I fix this ? Thanks for all your helps
Is there featureds directory in storage?
If no, you use mkdir to create directory because Intervention don't create directory automatically.
I am working on cakephp based project
Making thumbnails using phpThumb plugin
need to create thumbnail of an external image link
phpThumb is generating thumbnail from this server
http://watermark.propspace.com
but not from this server
https://propspaceuae.s3.amazonaws.com
i am getting this error Off-server thumbnailing is not allowed
to solve this i did the following
in phpThumb.config.php file
i changed nohotlink_enabled false
$PHPTHUMB_CONFIG['nohotlink_enabled'] = false;
and added domain on nohotlink_valid_domains
$PHPTHUMB_CONFIG['nohotlink_valid_domains'] = array(#$_SERVER['HTTP_HOST'],'propspaceuae.s3.amazonaws.com');
but not worked for me
i found this solution here Link
but this is not working for me.
I got the solution by changing this line
$PHPTHUMB_CONFIG['nohotlink_enabled'] = false;
to
$PHPTHUMB_CONFIG['nohotlink_enabled'] = true;
and i added domain in phpThumb.class.php file
var $config_nohotlink_valid_domains = array('propspaceuae.s3.amazonaws.com');
And it worked for me.
I am using Bacon/BaconQrCode library to generate Qr-Code image so how can
save the Qr-code images to the specific folder ?? please help.
My Code:-
$renderer = new \BaconQrCode\Renderer\Image\Png();
$renderer->setHeight(256);
$renderer->setWidth(256);
$writer = new \BaconQrCode\Writer($renderer);
$writer->writeFile('www.google.com', 'qrcode.png');
How can I save this Qr-code image to the folder to show or fetch from other location.
The \BaconQrCode\Writer->writeFile uses file_put_contents method so you can just add an absolute path to your directory like : $writer->writeFile('www.google.com', '../public/qrcodes/qrcode.png');
I haven't tried yet but i hope it works for you.