What extensions and approaches are good for image resizing and optimization? [duplicate] - imagick

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How do you create .webp images using PHP?
Modern versions of PHP (>= 5.5.0) can be compiled with WebP support but from I've seen this isn't common on many web hosts. If compiled with WebP support you can use the built-in imagewebp() function to create .webp images.
What are the alternatives for creating .webp images using PHP? Libraries, APIs other methods?

The options currently available are: gd (extension), imagick (extension), imagick (exec-call), gmagick (extension), gmagick (exec-call), cwebp (exec-call), gmagick (exec call) or calling a cloud service. I have created a library 'webp-convert' on github which tries all methods. The readme-file describes the pros and cons of each method. Its available here: https://github.com/rosell-dk/webp-convert.
For reasons unknown to me, the imagick/gmagick extensions produces no better quality than the original files. This is only a problem with the extensions, not the exec calls.

webp images creating process:
you can use following php commands,to get the webp images
$imgName = "codingslover.jpg";
$webPName = "codingslover.webp";
Syntax:
cwebp [quality qualitypercentage] [source image] -o [destination]
exec("cwebp -q 0 ".$imgName." -o ".$webPName." ");
Anthor Method:
exec("convert -colorspace RGB ".$imgName." ".$webPName . " ");
Exec : executes the given command in php
http://php.net/manual/en/function.exec.php

You can go right to Google and build the WebP libraries from source. Use this link to get the appropriate archive for your operating system:
https://developers.google.com/speed/webp/docs/compiling#building
Then you can use the following command within a php system() function to convert the images:
Syntax:
cwebp [quality
qualitypercentage] [source
image] -o [destination]`
cwebp -q 80 source.png -o
destination.webp
I would recommend reading the above link to get your libraries compiled, then go here to get more information about using the libraries.
Best of luck with the project!

You can use Intervention Image Library. It provides various image encoding options and utilities related to image formatting. Here is the sample code snippet to convert image into webp format. It supports numerous image encodings as listed below,
jpg — return JPEG encoded image data
png — return Portable Network Graphics (PNG) encoded image data
gif — return Graphics Interchange Format (GIF) encoded image data
tif — return Tagged Image File Format(TIFF) encoded image data
bmp — return Bitmap (BMP) encoded image data
ico — return ICO encoded image data
psd — return Photoshop Document (PSD) encoded image data
webp — return WebP encoded image
data data-url — encode current image data in data URI scheme (RFC 2397)

There are now several npm packages to create .webp images from PNG, JPEG and TIFF formats.
Here's one Gulp plugin as an example - gulp-webp.

Related

Add inline .svg image in Rmarkdown

I have used ![](https://image.png){width=25px} for inline image but it seems not working with .svg image.
Is there any way that I can use this image in my rmarkdown?
You could use the R package rsvg to convert the SVG to PDF
rsvg::rsvg_pdf(svg = "https://upload.wikimedia.org/wikipedia/commons/1/15/Florida_in_United_States.svg",
file = "image.pdf")
and then include that PDF as you're used to
![](image.pdf){width=25px}
You could also convert the SVG to another image format supported by knitr using the other rsvg::rsvg_* converter functions, e.g. to PNG via rsvg::rsvg_png(). But I'd recommend to stick with vector image formats like PDF or EPS since they will print in crisp sharpness.
Note that if you install rsvg from source (likely the case on Linux), additional system dependencies are required.

what is the valid format for a tiff image in python

How do I write a valid tiff image in python with my own data for the tiff file?
I've tried doing a few things using PIL and it's not a valid image.
If you could answer with some sample code of making a tiff image then editing the data using PIL that would be more than enough and go a long way in moving my program along
Are you required to exactly use PIL? Otherwise, have you tried using it's open source clone called Pillow? Refer to https://python-pillow.github.io/
Pillow seems to be able to directly save image data in tiff file format.
Try something like:
img = Image()
# any editing of 'img'
img.save( 'mytiff.tif' )
Otherwise, you should clarify your needs or problems in depth.

If i am making a image sharing service website using the standard file upload form what images can i say it supports, other then jpg, png, gif

If i am making a image sharing service website using the standard file upload form what images can i say it supports, other then jpg, png, gif. Is there a list that shows what browsers supports what? I know that jpg png and gif are most common but what are the others. I want to be sure.
Honestly, that's pretty much all you should be concerned with. Any other file formats (like svg) are not widely supported enough.
I would suggest converting other types of files to those 3
Examples:
jpeg (simple renaming)
bmp
tiff
pcx

Includegraphics problems with a PNG [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have problems to insert an image into my .tex file. This is the code:
\begin{figure}
\includegraphics[width=1\textwidth]{Blockdiagram}
\caption{Diagram}
\label{figure:BlockDiagram}
\end{figure}
It says that it cannot find the file! The same with Blockdiagram.png.
The figure is in the same folder. The main .tex is outside this folder, and I tried copying the image there, but the problem persists.
If I type H for help I have:
I could not locate the file with any of these extensions: .eps, .ps....
It's a png! In the file I have both:
\usepackage{graphicx}
\usepackage{epsfig}
And I tried commenting epsfig.... but nothing happens. Same error.
Any ideas?
EDIT: I have several PNG files, is it possible to use PNG files? I am using LEd under WinXP.
You could use PDFLaTeX instead of LaTeX. PDFLaTeX can import PNG images. You cannot use EPS images in PDFLaTeX, though; you would have to use PDF as a vector image format. I would recommend to use ImageMagick to convert images.
Andy & Svante are right: you are generating a DVI file & graphicx handles graphics in DVI files using Postscript specials, which can't handle PNGs. When generating a PDF, the graphicx can handle PNGs (and not .eps).
What's confusing is that using Pdftex does not ensure that you generate a PDF: if you invoke Pdftex with latex, it drops back into Web2c-compatibility mode, and generates a DVI. You mush explicitly invoke it using pdflatex.
Or use Xetex, which these days only generates PDFs. Invoke that with xelatex, if you have it.
There's no way to use both EPS figures and PNGs natively in one Latex file (at least not until Taco Hoekwater implements his Postscript interpreter in Luatex...), and 'til then, you must choose and use one of the many fine converters that are available.
Try using sam2ps to convert your images to eps format - I had a similar problem once where building to DVI would work with PNGs, but building to PDF would then fail unless I had EPS files.
latex is looking for Blockdiagram.eps, not Blockdiagram.png . Ideally you should try to use graphics in vector eps format. How did you create your diagram? (what software etc?)
E.g. matlab can export to eps as well as png. Inkscape is a good program for drawing vector images from scratch.
edit:
to convert you can use sam2p or this online tool

How to modify a .png image with VBScript

I have a need to select a portion of a .png file, with specific cordinators, and delete this area then save the file back with the same name.
I would appreciate if you can help to come up with a VBScript script that can accomplish this task.
It would be great if all proesses happen in the background, but it would be ok too if the image file has to be open and visible. Thanks a bunch!!!
A PNG file, like any other binary file can be edited with CMD or VBS.
A PNG file layout is as follows:
File header
"Chunks" within the file
Pixel format
Transparency of image
Compression
Interlacing
Animation
Read the PNG format in RFC 2083 to know how to edit/create a PNG file at binary/bit level.
To speed up the editing process, libraries are available for application level editing.
Here are some VBA codes for image manipulation.
ImageMagick also provides libraries that can be accessed via VBS for image editing.
Here's a VBScript Image Class for bmp and pcx files (which PNG can be converted to before editing via WIA).
Loadpicture function described here doesn't seem to support PNG, but this discussion might solve it.
The Windows Image Acquisition Library v2.0 supports PNG, BMP, JPG, GIF and TIFF image formats, and comes with Windows Vista and later versions. Sample scripts are available to demonstrate "image manipulation using the ImageFile object". The Vector.ImageFile property also "creates an ImageFile object from raw ARGB data".
More sample codes here & here show how to rotate, flip, scale, crop, etc with WIA Image constants in vbs. To remove unwanted areas of image (with given coordinates), use the crop function.
Here's a discussion of WIA 2.0 image editing on stackoverflow.
VBScript doesn't have any image editing functions, so you need an external tool for that. For example, GIMP can do image processing from the command line (see here). ImageMagick provides a scriptable component in addition to the command-line interface (details here).
To run a command line from a VBScript script, you can use the WShShell.Run method. To create an instance of a COM scriptable component, use the CreateObject function.

Resources