Gif to png linux

Convert GIF image to PNG on the fly

I am using pdflatex on Linux and attempting to convert GIF to PNG. I can run scripts to find out the image attributes and even and convert the files supplied from a folder but I can not write back to that folder (or I’d convert them by hand). I have hundreds of gif files. I have found great instructions with regard to converting GIF to EPS. Those weren’t working for me, so I thought I’d try PNG files because I normally use PNG files. Thanks in advance for your time for reading and any comments. Before \begin , I have defined:

\DeclareGraphicsExtensions \DeclareGraphicsRule<>
! LaTeX Error: Cannot determine size of graphic in `convert figures/filename.gif 'png:-' (no size specifed). 

I got the dimensions using imagemagick’s identify command. I am able to convert the file, write it to a new file, and view it using imagemagick:

$ convert figures/filename.gif gif:figures/filename.png 

I believe that the «convert» command I specified in the graphics rule is not actually running. What am I doing wrong? Here are some details about my build:

$ pdflatex test.tex This is pdfTeX, Version 3.14159-14h-released-20010417 (Web2C 7.3.3.1) (./test.tex LaTeX2e Babel and hyphenation patterns for american, french, german, ngerman, i talian, nohyphenation, loaded. (/usr/share/texmf/tex/latex/base/article.cls Document Class: article 2001/04/21 v1.4e Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size10.clo)) (/usr/share/texmf/tex/latex/tools/verbatim.sty) (/usr/share/texmf/tex/latex/fancyhdr/fancyhdr.sty) (/usr/share/texmf/tex/latex/graphics/graphicx.sty (/usr/share/texmf/tex/latex/graphics/keyval.sty) (/usr/share/texmf/tex/latex/graphics/graphics.sty (/usr/share/texmf/tex/latex/graphics/trig.sty) (/usr/share/texmf/tex/latex/config/graphics.cfg) (/usr/share/texmf/tex/latex/graphics/pdftex.def))) (/usr/share/texmf/tex/latex/base/makeidx.sty) Writing index file test.idx (/usr/share/texmf/tex/latex/misc/pslatex.sty) (/usr/share/texmf/tex/latex/pdfpages/pdfpages.sty (/usr/share/texmf/tex/latex/base/ifthen.sty) (/usr/share/texmf/tex/latex/tools/calc.sty) (/usr/share/texmf/tex/latex/ms/eso-pic.sty (/usr/share/texmf/tex/latex/ms/everyshi.sty)))) LaTeX Warning: Unused global option(s): [8pt,english]. No file test.aux. (/usr/share/texmf/tex/latex/psnfss/omspzccm.fd) (/usr/share/texmf/tex/context/base/supp-pdf.tex (/usr/share/texmf/tex/context/base/supp-mis.tex loading : Context Support Macros / Missing ) loading : Context Support Macros / PDF ) (/usr/share/texmf/tex/latex/psnfss/ot1ptmcm.fd) (/usr/share/texmf/tex/latex/psnfss/omlptmcm.fd) (/usr/share/texmf/tex/latex/psnfss/omxpsycm.fd) [1] (/usr/share/texmf/tex/latex/psnfss/omsphv.fd) [2] [3] [4] (./test.aux) ) 

Источник

Конвертация изображений в любые форматы в Linux

В Linux имеется пакет ImageMagick, который поддерживает сотни форматов изображений и может конвертировать картинку любого формата в любой другой.

С конвертированием изображений (JPG и других форматов) отлично справляется утилиты convert и magick из пакета ImageMagick.

Подробности по установке ImageMagick, в том числе какие зависимости необходимо установить для поддержки максимального количества форматов, смотрите в статье: Руководство по ImageMagick: установка, использование и решение проблем

Полный список поддерживаемых форматов вы можете просмотреть командой

Также в конце статьи приведена таблица с полным перечнем поддерживаемых форматов файлов и ихкратким описанием.

Как конвертировать картинки в командной строке Linux

Чтобы конвертировать одно изображение в любой другой выполните команду вида:

magick КАРТИНКА РЕЗУЛЬТАТ

Примечание: если вы получили сообщение об ошибке, что команда magick не найдена, то вместо неё используйте команду convert. Объяснение будет дано ниже.

Читайте также:  Задать ip linux ifconfig

Программа автоматически определит исходный формат изображения.

Что касается формата выходного файла, то он определяется по указанному в предыдущей команде расширению.

magick КАРТИНКА.jpg РЕЗУЛЬТАТ.png

Следующая команда конвертирует файл image.png в формат JPG и сохранит новую картинку в файл image.jpg:

Вы также можете конвертировать динамические изображения (например, GIF файлы) в видео ролики (форматы avi, 3gp, webm, wmv, flv, mkv, mpg, webm, m2v, m4v, mov, mp4, mpeg и другие).

Также вы можете конвертировать видео форматы avi, 3gp, webm, wmv, flv, mkv, mpg, webm, m2v, m4v, mov, mp4, mpeg и другие в файлы GIF.

Как сжать изображение при конвертировании

О том, как одновременно конвертировать и уменьшить размер изображения смотрите в статье: Уменьшение размера фотографий. Массовое изменение размера фотографий в командной строке

Конвертация картинок во все форматы онлайн

Если вы не хотите устанавливать пакет ImageMagick или являетесь пользователем Windows, то вы можете воспользоваться онлайн конвертацией изображений в любые форматы. Это бесплатный онлайн сервис, вам достаточно указать картинку для конвертации и выбрать желаемый формат нового файла.

Источник

Gif to png linux

NAME

gif2png - convert GIFs to PNGs

SYNOPSIS

gif2png [-bdfghinprsvwO] [file.[gif]. ]

DESCRIPTION

The gif2png program converts files in the obsolescent Graphic Interchange Format (GIF) to Portable Network Graphics (PNG) format, an open W3C standard. Normally gif2png converts each file named on the command line, leaving the original in place. If a name does not have a .gif extension, the unmodified name will be tried first, followed by the name with .gif appended. For each file named foo.gif, a foo.png will be created. When a multi-image GIF file named foo.gif is converted, gif2png creates multiple PNG files, each containing one frame; their names will be foo.png, foo.p01, foo.p02 etc. If no source files are specified and stdin is a terminal, gif2png lists a usage summary and version information, then exits. If no source files are specified, and stdin is a device or pipe, stdin is converted to noname.png. (The program can't be a normal stdin-to-stdout filter because of the possibility that the input GIF might have multiple images). However, if filter mode is forced (with -f) stdin will be converted to stdout, with gif2png returning an error code if the GIF is multi-image. The program will preserve the information contained in a GIF file as closely as possible, including GIF comment and application-data extension blocks. All graphics data (pixels, RGB color tables) will be converted without loss of information. Transparency is also preserved. There is one exception; GIF plain-text extensions are skipped. The program automatically converts interlaced GIFs to interlaced PNGs. It detects images in which all colors are gray (equal R, G, and B values) and converts such images to PNG grayscale. Other images are converted to use the PNG palette type. Duplicate color entries are silently preserved. Unused color-table entries cause an error message. The action of the program can be modified with the following command-line switches: -b RRGGBB Background. Replace transparent pixels with given RGB value, six hexadecimal digits interpreted as two hexits each of red, green, and blue value. The value may optionally be led with a #, HTML-style. -d Delete source GIF files after successful conversion. -f Filter mode. Convert GIF on stdin to PNG on stdout, return error if the GIF is multi-image. -m Preserve file modification time. the PNG output gets the mod time of the input file, not the time it was converted. -g Write gamma=1/2.2 and sRGB chunks in the PNG. -h Generate PNG color-frequency histogram chunks into converted color files. -i Force conversion to interlaced PNG files. -n Force conversion to non-interlaced PNG files. -p Display progress of PNG writing. -r Try to recover data from corrupted GIF files. -s Do not translate the GIF Software chunk to a PNG annotation. -v Verbose mode; show summary line, -vv enables conversion-statistics and debugging messages. -w Web-probe switch; list GIFs that do not have multiple images to stdout. GIFs that fail this filter cause error messages to stderr. -O Optimize; remove unused color-table entries. Normally these trigger an error message and disable -d (but conversion is completed anyway). Also, use zlib compression level 9 (best compression) instead of the default level. The recovery algorithm enabled by -r is as follows: Unused color table entries will not trigger an error message as they normally do, but will still be preserved unless -O is also on, in which case they will be discarded. Missing color tables will be patched with a default that puts black at index 0, white at index 1, and supplies red, green, blue, yellow, purple and cyan as the remaining color values. Missing image pixels will be set to 0. Unrecognized or corrupted extensions will be discarded.

PROBLEMS

Naively converting all your GIFs at one go with gif2png is not likely to give you the results you want. Animated GIFs cannot be translated to PNG, which is a single-image format. The web-probe switch is intended to be used with scripts for converting web sites. In versions of this tool up to 2.5.2 it filtered out GIFs with transparency as well as GIFs with animations, but support for PNG transparency has been universal in browsers since about 2006.

STANDARDS AND SPECIFICATIONS

Copies of the GIF89 specification are widely available on the Web; search for "GRAPHICS INTERCHANGE FORMAT". The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated. The GIF format was formerly covered by a blocking patent on LZW compression, but it expired in June 2003. The PNG home site at http://www.libpng.org/pub/png/> has very complete information on the PNG standard, PNG libraries, and PNG tools.

SEE ALSO

AUTHORS

Code by Alexander Lehmann alex@hal.rhein-main.de>, 1995. Auto-interlace conversion and tRNS optimization by Greg Roelofs newt@pobox.com>, 1999. Man page, -O, -w, and production packaging by Eric S. Raymond esr@thyrsus.com>, 1999. -m option by Steve Ward, 2012.

Источник

Читайте также:  Install webstorm on linux

How do I convert (.gif to .png) this image to get the original view?

I am trying to convert this image, http://en.wikipedia.org/wiki/File:Dijkstra_Animation.gif, to a series of .png files. This was pretty simple, I used the convert command in Linux:

convert Dijkstra_Animation.gif dijkstra.png 

The command went fine and produced the 27 frames, as reported at the bottom of the original page. However, I find that some of the produced .png files are only single numbers or arrows. Which is different from what I expected. I want the .png files to be a simple sequence in the same way the .gif file is showing. Could you please suggest a method (for Linux please) to achieve this?

2 Answers 2

Using the -coalesce option will do the wonder.

convert -verbose -coalesce Dijkstra_Animation.gif dijkstra.png 

Actually the -coalesce option «merges a sequence of images» as is claimed in the manual page.

jalal@klein:~$ convert -verbose -coalesce MRtIA77.gifv rabbit.jpg convert: no decode delegate for this image format GIFV’ @ error/constitute.c/ReadImage/501. convert: no images defined rabbit.jpg’ @ error/convert.c/ConvertImageCommand/3210.

If convert does not work for you and you are a Mac user, you can try sips , which comes with your MacOS. For example, you can convert a GIF image into a PNG image:

sips -s format png 1.gif --out 1.png 

You can also convert a folder filled with GIFs to PNGs saved in folder pngs:

sips -s format png gifs/*.gif --out pngs 

More about sips . It is an abbreviation of Scriptable image processing system. It is used to query or modify raster image files (JPG/GIF/PNG). Image processing options include flip, rotate, change image format/width/height. You can find more details in its manual: in command line man sips or at online manual.

Читайте также:  Linux scp несколько файлов

FYI, my MacOS release (obtained by uname -rsv ) is:

Darwin 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 

Источник

Оцените статью
Adblock
detector