How are images shown in the terminal - linux

Some packages like w3m-img, fim, lsix etc can be used to show the images directly on the terminal itself on linux.
I am not talking about converting the image into an ASCII character version and showing it but the image itself which looks proper without any the artifacts.
so how do these programs actually draw the images onto the terminal?

I've used Feh in the past. It should be already installed on popular Linux distributions. To use it, simply do the following:
feh your-image.jpeg

Related

linux console how to change the codepage to dos cp437

I want to view some ansi-art on the linux local-console. (my setup:raspberry pi3 / newest raspbian - no x11)
i've tried many different settings in raspi-config, dpkg-reconfigure console-setup, /etc files, environment vars but i had no luck yet. do i need a special pcf font to get it working?
a reliable way to enable it for remote terminals would also be great.
thanks in advance
It depends on what your data uses (see chart). Codes 0..31 are a problem unless you have a program that can map those codes to a printable value (as noted in Why does showconsolefont have different output in tmux?, the showconsolefont program does this mapping of 0..31).
Most of the usable fonts for the Linux console are "psf" fonts: having a header which tells which Unicode values each glyph corresponds to. Using that, along with a known character set (cp437), you could convert the data or "play" it using an application which knows how to do this:
You could convert it using iconv or recode, or
The line-drawing (128..255) could be done using luit in a UTF-8 console.

How do you programmatically - or from CLI - rotate a PDF?

What I need to be able to do is to rotate a PDF clockwise or counter clockwise either programmatically or from the CLI.
I have spent considerable time researching and attempting to rotate PDFs with GhostScript (as GS is already installed for other reasons) to no avail, nothing seems result in any rotation.
I have looked into using pdftk but it requires java libraries, and I would rather not have java installed on the system.
We've even looked at modifying the PDF file ourselves, and we have had some success with this, but we haven't come across a reliable method that works for all PDFs.
So my #1 preference would be to achieve this with existing resources on the system.
My #2 preference would be to do a little modification to the existing system as possible to achieve this.
The server in question is using Linux (OpenSuse 11) with PHP 5.2 and I have Ghostscript 9.0 installed.
Any advice would be much appreciated.
You can use pdfpages LaTeX package
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[angle=45]{document.pdf}
\end{document}
The LaTeX document above, compiled via pdflatex, produces a document rotated 45 degrees.
There are also tools (wrappers of pdfpages) like pdfjam that can be used directly from command line:
$ pdfjam --suffix rotated45 --angle 45 --fitpaper true document.pdf
There is a way to do this with ImageMagick, if that's available to you.
Example:
$ convert originalfile.pdf -rotate <cw_angle_degrees> newfile.pdf
Note, however, that since this is a raster-based rotation, there will (generally) be a noticeable loss of quality AND increase in filesize.
You haven't said how you are trying to do this with Ghostscript, but if you want to use the pdfwrite device you will need to set /AutoRotatePages=/None or it will rotate the final page so that the majorty of any real text is horizontal.

Not getting UI display with Skia library tests on ubuntu

I followed the steps from skia site for compiling skia r1236 on my Ubuntu 12.04 64 bit machine.
When i run the tests , no window comes up to show the graphical result.The output on console is :
[1/33] PDFPrimitives...
...................
[33/33] BitmapCopy...
Finished 33 tests, 0 failures.
If i put a Bitmap to a file using SkImageEncoder::EncodeFile , i do get graphical output on the file. This confirms that the library is working fine but is not able to invoke linux window system.
Another problem is that while running text , i get following error
SkFontHost::OpenStream failed opening 1
--- no context for glyph 0
I have installed all freetype libraries as described by the Skia website , but still have error whichever path i use in SK_FONT_FILE_PREFIX.
My "/usr/share/fonts/" folder have
cmap
truetype
type1
X11
I noticed there is a file SkOSWIndow_Unix.cpp but nobody seems to be calling it from the test code.So my question is
1) How do we get the output to be shown on a window?
2) WHat should be the value of SK_FONT_FILE_PREFIX?
PS : The Windows port worked fine
Skia r1236 is at least two years old; you should be using something newer. The directions on the website are less than a year old.
The Linux tests and the Windows tests produce the same thing. You should see the same result from Linux as you did from Windows.
Part of the question is which particular tests you are running. From your description of the Linux shell output, these were the "gm" tests, which do not display windows. They draw pictures onto off-screen canvases.
With the "-w " option, gm will write the images as pngs into a directory.
With the "-r " option, gm will read images from a directory and compare them to the images it generates.
The SampleApp application in Skia does use the Linux window system. However, we do not support the "views" library that was used to create it. Skia is a platform-independent rendering engine; you'll need to provide your own windows management.
Note that gm functions a bit differently since somtime in the 6000s or 7000s; a default checkout will no longer contain the reference images for all GMs on all platforms.

Render swf to png or other image format

How can I, on linux, render a swf to a image file?
I need to be able to load other swfs into that swf and run actionscript code.
Is it even possible on linux? I need to do it from PHP, it's fine if I have to use command-line tools.
swfrender from swftools works for basic SWF files.
swfdec-thumbnailer from swfdec-gnome works though it only gets the first frame of the swf.
To get any frame from swf using swfdec see the C code snippet in the following mailing list post.
gnash from gnash also works gnash -s<scale-image-factor> --screenshot last --screenshot-file output.png -1 -r1 input.swf, last image of the swf.
ffmpeg from ffmpeg also works for some swf formats ffmpeg -i movie.swf -f image2 -vcodec png movie%d.png
Also see the following guide for a commandline pipeline.
In order to call external programs from php you use the exec command documented here.
Note that for security reasons it is important to escape arguments passed to exec with another command like escapeshellcmd or escapeshellarg for security reasons.
Once you have converted to an image format whether for single frame or all frame, you can't run action script. Other non GNU / Linux tools support the export of the action script from from SWF.
If the SWF that you are exporting to PNG is too complicated for the other tools than you can use the Flash Plugin or Gnash and Xvfb along with screen capture software to capture either image frames of the SWF or a video format like avi. Then you can extract the images from the video format.
This virtual framebuffer method will support complicated SWF files, though it requires a lot of work as you need to use either Gnash and Xvfb and Screen Capture, or a browser , Xvfb and Selenium, if you want to capture a certain set of mouse / keyboard interactions with the SWF.
Gnash with and without the Virtual FrameBuffer should load the ActionScript before exporting, but may have issues with complicated ActionScript. Flash Plugin with Virtual Framebuffer will load the ActionScript before exporting.
Also see the following StackOverFlow questions, which you question is a duplicate of
Convert SWF to PNG
Render Flash (SWF) frame as image (PDF,PNG,JPG)
SWF to image (jpg, png, …) with PHP
This is the solution I ended up using.
You can use a tool like Xvfb (X11 server) and run the standalone flash player projector inside it (you may need to install a bunch of 32-bit libraries), then use a screen capture utility like import to capture the screen and crop it to size.
I found this page on rendering swf screenshots in linux helpful. It also says that you can use gnash to do this, however gnash won't work for flash player 9+.
Try this air application http://swfrenderer.kurst.co.uk
It render swf frame by frame

Show image notification from bash script

What I'm trying to accomplish:
On Ubuntu 10.04 I'd like to display a small notification image in the corner of the screen and have the image fade out. I'd like to do it from the command line for use with bash scripts. Similar to "notify-send", "zenity", or "dialog" except
it displays images as well.
What I've found so far:
ImageMagick animate seems to be the only command line tool that can display an image and exit without user interaction.
Is there anything any better? I could write one myself but I thought there should already be something to do this.
gcin does the work. It shows full size images as notifications.
sudo apt-get install gcin
gcin-message -icon your_image.jpg
Extract of man gcin-message:
NAME
gcin-message - gcin's notification tool
SYNOPSIS
gcin-message [-icon file] [-text string] [-duration milliseconds]
DESCRIPTION
gcin-message displays notification image and/or text. It is useful for
filters to have interaction with users.
OPTIONS
-icon file
Display an image.
-text string
Display text string. The space character is not allowed.
-duration milliseconds
Time to show notifications.
However I suggest you to not use this tool, because its installation from the Ubuntu repository is not fine grained (6 MB of stuff and a chinese icon in the notification area).
See if you can get gcin-message out of the gcin package and put it into your own package (if this suits your needs).

Resources