# Tag Info

27

In bash: for f in *.jpg; do convert ./"$f" ./"${f%.jpg}.pdf" done

27

You can use the mogrify command for this. Normally, it modifies files in-place, but when converting formats, it writes a new file (just changing the extension to match the new format). Thus: mogrify -format pdf -- *.jpg (Like enzotib's ./*.jpg, the -- prevents any strange filenames from being interpreted as switches. Most commands recognize -- to mean ...

22

Here's a small Python script using the PyPdf library that does the job neatly. Save it in a script called un2up (or whatever you like), make it executable (chmod +x un2up), and run it as a filter (un2up <2up.pdf >1up.pdf). #!/usr/bin/env python import copy, sys from pyPdf import PdfFileWriter, PdfFileReader input = PdfFileReader(sys.stdin) output = ...

17

Last time I used convert for such a task I explicitly specified the size of the destination via resizing: $convert a.png b.png -compress jpeg -resize 1240x1753 \ -units PixelsPerInch -density 150x150 multipage.pdf Where 1240x1753 are exactly DIN A4 when 150 DPI is chosen. I computed the values using bc and looked up the dimensions ... 13 It's not clear what you mean by "quality loss". That could mean a lot of different things. Could you post some samples to illustrate? Perhaps cut the same section out of the poor quality and good quality versions (as a PNG to avoid further quality loss). Perhaps you need to use -density to do the conversion at a higher dpi: convert -density 300 file.pdf ... 12 OpenOffice comes with the unoconv program to perform format conversions on the command line. unoconv -f csv filename.xlsx For more complex requirements, you can parse XLSX files with Spreadsheet::XLSX in Perl or openpyxl in Python. For example, here's a quickie script to print out a worksheet as a semicolon-separated CSV file (warning: untested, typed ... 11 Use the convert command from ImageMagick: convert x.png -resize 25% x.jpg will create a 25%-scaled JPEG version of x.png. To do all the PNG files at once, use a for loop: for filename in *.png ; do convert "$filename" -resize 25% "${filename%.png}.jpg" ; done We look at every file matching *.png, and for each one run the convert command above. ... 10 xxd -b (source) 10 One way is to use pdflatex instead of convert. You need in a extra file, which is here called image.tex: \documentclass{article} \usepackage[active,tightpage]{preview} \usepackage{graphicx} \PreviewMacro[{*[][]{}}]{\includegraphics} \begin{document} \includegraphics{img.jpg} \end{document} Then run pdflatex image.tex to generate image.pdf. 9 Here is a way that combines the best of the above suggestions into a simple, efficient, robust command line: find /path/to/files -iname '*.jpg' -exec mogrify -format pdf {} + It works fine with filenames that begin with a - or contain spaces. Note the use of -iname which is the case-insensitive version of -name so it will work on .JPG just as well as ... 9 take a look at this: http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast/107735#107735 ..... After the Desktop Recorder has saved the recording into an OGV video, MPlayer will be used to capture JPEG screenshots, saving them into the 'output' directory. On a terminal: mplayer -ao null <video file name> -vo ... 8 Imagemagick can do it in one step:$ convert in.pdf -crop 50%x0 +repage out.pdf

8

Ok, first things first... ffmpeg's sameq option doesn't mean same quality, and in many cases will not do anything relevant. This is from the ffmpeg man page: -sameq Use same quantizer as source (implies VBR). This is actually from the ffmpeg online documentation ‘-same_quant’ Use same quantizer as source (implies VBR). Note that this is NOT ...

8

faster and less painful syntax: parallel convert '{} {.}.pdf' ::: *.jpg Runs in parallel (using https://www.gnu.org/software/parallel/).

8

(adapted from comments above) Depending on the codecs used (some codecs are incompatible with some containers), you could always simply copy the streams (-codec copy). That is the best way to avoid quality changes, as you're not reencoding the streams, just repackaging those in a different container. When dealing with audio/video files, it is important to ...

7

The fundamental tool for sound format conversions and simple transformations is SoX, the Swiss Army knife of sound processing programs. sox foo.mp3 foo.flag If you're running Debian, support for writing MP3 in sox is broken in lenny and squeeze (and as far as I know the same problem affects Ubuntu 10.04 and 10.10). This bug was fixed in early March 2011, ...

7

One method is to use CUPS and the PDF psuedo-printer to "print" the text to a PDF file. Another is to use enscript to encode to postscript and then convert from postscript to PDF using the ps2pdf file from ghostscript package.

7

You may also try to use ffmpeg to create a movie out of a sequence of images and then convert the movie to a GIF animation (again using ffmpeg). # cf. http://pages.uoregon.edu/noeckel/MakeMovie.html # first convert an image sequence to a movie ffmpeg -sameq -i %03d.jpg output.mp4 # ... and then convert the movie to a GIF animation ffmpeg -i output.mp4 ...

7

Yes, there is. Though its name is djvutxt, not djvu2text. It is part of: the djvu package on Gentoo. the djvulibre-bin package on Debian/Ubuntu.

6

By default, iconv refuses to convert the file if it contains characters that do not exist in the target character set. Use //TRANSLIT to “downgrade” such characters. iconv -f utf-8 -t iso8859-1//TRANSLIT

6

What you really want to use is: $convert a.png b.png -compress jpeg -resize 1240x1753 \ -extent 1240x1753 -gravity center \ -units PixelsPerInch -density 150x150 multipage.pdf -extent actually extends the image to be 1240x1753, while -resize keeps the image's ratio, fitting it into either 1240x... or ...x1753. ... 6 It is a double byte format, probably UTF-16. See if you can identify a BOM (Byter Order Mark) header at the beginning of the file. This will tell you the encoding if it is present, although it may not be. Note that a text editor may hide this from you, so you will probably need to look at the file with a hex dump utility such as od or something similar to ... 6 potrace I found this example on SO in a Q&A titled: How to convert a JPEG image into SVG format using ImageMagick?. One of the answers suggested potrace.$ convert input.jpg output.ppm $potrace -s output.ppm -o svgout.svg Results ... 5 I'm using Perl's xls2csv to convert xls files to csv. Not sure tho if it works with xlsx too. About: It can't be comma separated unfortunately since some columns have commas in them that's why quoting has been introduced: 1,2,"data,data, more data" 5 You can do this using bsdtar: ire@localhost: bsdtar -cvf pax.tar --format=pax @gnu.tar ire@localhost:file gnu.tar gnu.tar: POSIX tar archive (GNU) ire@localhost:file pax.tar pax.tar: POSIX tar archive @archive is the magic option. From the manpage: @archive (c and r mode only) The specified archive is opened and the entries in it will be ... 5 First of all, -aq sets a quality-based variable bit rate - I think you're looking for -ab (note that I'm an ffmpeg user, so my knowledge of avconv syntax is limited - I've no idea how far it's drifted since the fork). Regardless, the built-in avconv/ffmpeg AAC encoder is pretty bad. fdk_aac The only really good AAC encoder for avconv/ffmpeg is libfdk_aac ... 5 With a recent version of xclip (the -t option was added in 2010 but not released yet AFAICT, so you'd need to get it from subversion, or use the one packaged in Debian). xclip -o -selection clipboard -t text/html | pandoc -r html -w markdown And if you want to make that back into the clipboard: xclip -o -selection clipboard -t text/html | pandoc -r ... 4 sox version 13 and up supports FLAC, along with many other formats. sox can do many things to an audio file, not just convert from one format to another. It is to audio what ImageMagick is to graphics. 4 The perl CGI module has a escapeHTML function that makes it pretty easy: perl -e 'use CGI qw(escapeHTML); print escapeHTML("<hi>\n");' Or to do an entire file: perl -p -e 'BEGIN { use CGI qw(escapeHTML); }$_ = escapeHTML(\$_);' FILENAME

Only top voted, non community-wiki answers of a minimum length are eligible