tinypng | Simple API client for TinyPNG.org | Compression library
kandi X-RAY | tinypng Summary
kandi X-RAY | tinypng Summary
TinyPNG is a simple API client for TinyPNG.org, which compresses your PNG images by 50-70% while preserving full transparency. This gem was initially created by reverse engineering the TinyPNG website. Since then, TinyPNG has begun developing an Official API which is in alpha stages. In the future, an API key will be required to use the TinyPNG API and gem.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Shows an image .
- Create a new image
- Get input parameter
tinypng Key Features
tinypng Examples and Code Snippets
Community Discussions
Trending Discussions on tinypng
QUESTION
I don't know if this has been asked before, please pardon in advance.
I created an image compression web app using the tinyPNG API, and it works as intended - that is users can upload an image file and it is compressed and saved in the server.
But then I create a download functionality for the user to download/save the compressed image.
On clicking the download link it throws up an error:
can’t find the file at http://localhost/var/www/html/imgtest/uploads/67403938_10219921906785196_7063388762713096192_n_1574687362.jpg.
Even though the compressed image is in the server.
Please help!!!
MY CODE:
...ANSWER
Answered 2019-Nov-25 at 13:34The problem in your code is, that you create the link with $compress_file
that contains absolute path to the file.
/var/www/html/imgtest/uploads/67403938_10219921906785196_7063388762713096192_n_1574687362.jpg
So when the link is clickend and the url is resolved in browser the result is
So if the localhost domain is pointed to /var/www/html/imgtest/
than the server is looking for the file in this path which doesn't exist:
/var/www/html/imgtest/var/www/html/imgtest/uploads/...
When you are generating the path to the compressed file you should put it's url into other variable where you wouldn't prepend the current directory.
QUESTION
I'm trying to modify this script to compress and then close all the opened files with the TinyPNG Photoshop plugin as opposed to having to choose one file at a time in an open dialog box. They do offer another script that allows you to compress a whole folder. However, I find myself needing to compress 10 out 50 images in a folder so I'd rather just be able to select those 10 or to open those 10 and run the script on all open files.
I've tried replacing
compressFile(File.openDialog("Choose a PNG or JPEG file to compress")
with
compressFile(app.activeDocument)
in an attempt to have the script just compress the current document.
Instead of using the active document it simply skips to the catch(error).
...ANSWER
Answered 2019-May-09 at 07:32compressFile()
requires a File
object while activeDocument
is a document
object.
For opened documents you'll want a loop through the documents:
QUESTION
I need compress images like a TinyPNG and save compressed images in dist folder. I use webpack 4 and found imagemin-webpack.But I don't understand what use: plugin or loader? Please, help to do configuration for this task.
...ANSWER
Answered 2019-Mar-12 at 12:16For compressing images in Webpack 4 I am using "img-loader".
QUESTION
ANSWER
Answered 2018-Dec-07 at 20:16tinypng --help
shows your solution:
tinypng -d tiny_pngs/ -- foo.jpg bar.png baz.png
which will shrink foo.jpg, bar.png, baz.png and download the shrinked files to tiny_pngs/ directory.
QUESTION
I have the following script that I got from tinypng.com and Instead of using the for f in "$@" command i would like it to just run inside the specified folder on desktop called FOLDER. Thanks!
...ANSWER
Answered 2018-Sep-25 at 15:18Assuming you are simply trying to iterate over files in a folder, than for f in ~/Desktop/FOLDER/*
should work.
Or alternatively for f in $(find ~/Desktop/FOLDER -maxdepth 1 -type f)
This one also removes any subfolders from the list so you may get rid of if [ -f $file ]
(but it also lists hidden files, not sure if that's OK for your case or not)
QUESTION
I am using react to edit an image and send its final data using mycanvas.toDataURL()
to php.
The API I am using says, instead of an image, I could although
[...] upload an image from a buffer (a string with binary)
Their example looks like this:
...ANSWER
Answered 2018-Apr-03 at 13:30You can try converting the string to an image file and then send that file, you can use a code like this to do that:
QUESTION
I want to use an API to compress images. It says the input can as well be a buffer (string with binary), for example:
...ANSWER
Answered 2018-Apr-03 at 11:13file_get_contents
returns the content of a file as string, and that string exactly represents the content of the file.
.toDataURL()
gives you a data url. The data:image/png;base64,
part tells that the following data represents a png and that the data is base64 encoded.
To get the same data representation as you get with file_get_content
you would need to decode the iVBORw0KGgoAAAANSUh...
So yes, both give you the content of a file, but they don't do that in the same way.
To toBlob
on the other hand will return a Buffer containing the data in the same representation as file_get_contents
would do.
QUESTION
I am using npm install --save tinify
then uploading my image files using nodejs but I need compressed .zip file in my system .
When I'm uploading my image files through browser at https://tinypng.com after uploading it shows download option that is perfect. But how can we do same through nodejs?
Here is my code:
...ANSWER
Answered 2017-Apr-28 at 08:01You can use tinify's method that converts and writes the compressed image at once:
QUESTION
I'm struggling to understand why my H1
does not show up. It is covered by a div
. The weird part is that the H1
's parent div
is visible if I change background
color to something else than transparent
.
Input tag inside the same div
is always visible as well. Only H1
is problematic.
Here is the link to the code: H1 does not show up And code HTML:
...ANSWER
Answered 2018-Mar-09 at 02:11The issue is the transform: scale
on .imageslider
, the content is exceeding the width of its parent. Then also having overflow: hidden;
is trimming anything outside the element.
QUESTION
I'm analyzing my site using Google PageSpeed Insights. It says "Properly formatting and compressing images can save many bytes of data." I've definitely done that as I'm uploading images that have been through https://tinypng.com/.
I think it's WordPress causing the issue by generating various responsive images as the warning is related to a filename -1024x525.png
which isn't the name of the file I uploaded.
Is this the automatically generated WordPress responsive images? If so, is there a way to optimize them? Google seems to think I can save ~30% which would be awesome.
...ANSWER
Answered 2017-Oct-27 at 10:52Use this plugin also which can you use in your site https://wordpress.org/plugins/w3-total-cache/
Here is optional things which you can use it.. https://wordpress.org/plugins/imagify
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tinypng
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page