Score:2

How do I zoom 200% in feh without having to use fullscreen?

sy flag

This works:

feh --zoom 200 --full-screen picturius.png

I need the same without full-screen:

feh --zoom 200 picturius.png # this does not work

Have you an idea where I am wrong?

Score:8
jp flag

feh basics

In Ubuntu I find the following description in man feh

 --zoom percent | max | fill
         Zoom images by percent when in full screen mode or when window
         geometry is fixed.  When combined with --auto-zoom, zooming will
         be limited to the specified percent.  Specifying max is like set‐
         ting --auto-zoom, using fill makes feh zoom the image like the
         --bg-fill mode.

Zoom works for me not only in full screen but also with fixed geometry according to the following example,

feh --zoom 200 --geometry 1500x500 zenity-info-message.png

Shellscript that makes feh --zoom nicer

The following shellscript fixes the geometry parameter automatically for each,

#!/bin/bash

function usage {

 echo "Help for ${0##*/} by Nio Wiklund <nio.wiklund at gmail.com>

Usage:
 ${0##*/} [--zoom <percent> [--position <+X+Y>]] <picture-1> [picture-2] [...]

Examples:

feh-zoom --zoom 200 picture.png
feh-zoom --zoom 50 --position +400+200 g*.jpg

    --zoom <percent>
        Zoom images by percent. Will create a correct window size automatically.
        . this option is modified in this shellscript compared to feh.
        
    --position <+X+Y>
        Position of the picture-window's top left corner
        (offset X pixels and Y pixels from the screen's top left cormer)
        . this is an option only for this shellscript, but not for feh.

    <picture-1> [picture-2] [...]
       . Specify at least one picture. Wild-card works, e.g. *.png
 
       . Switch to the next picture with 'q' (while you do it with -> in feh).
         Quit with 'qq' (press 'q' twice within one second).

       . The standard options for feh (for example --randomize) will fail
         because feh is called for one picture eash time in a for-loop, and
         no more options are passed.

If the first option is not --zoom, this shellscript passes control to feh
directly, so that all the standard options for feh will work.

General help for feh: man feh"
}
##############################
if [ "${1}" == "--zoom" ]
then
 shift
 if [ "$1" == "" ]
 then
  usage
 fi
 zoom="$1"

 shift
 if [ "$1" == "" ]
 then
  usage
 fi
 if [ "${1}" == "--position" ]
 then
  shift
  if [ "$1" == "" ]
  then
   usage
  fi
  position="$1"

  shift
  if [ "$1" == "" ]
  then
   usage
  fi
 fi
 cont=1
 for i in "$@"
 do
  if [ $cont -ne 0 ]
  then
   str="$(feh -l "$i"|tail -n1)"
   wide=$(<<< "$str" cut -f3)
   high=$(<<< "$str" cut -f4)
   wide=$((wide*zoom/100+1))
   high=$((high*zoom/100+1))
   geom="${wide}x${high}$position"
#   echo "$geom"
   feh --zoom "$zoom" --geometry "$geom" "$i"
   read -n1 -s -t1 ans
   cont=$?
  else
   exit 0
  fi
 done
elif [ "${1}" == "-h" ] || [ "${1}" == "--help" ]
then
 usage
else
 if [ "$1" == "" ]
 then
  feh
 else
  feh "$@"
 fi
fi

Make the shellscript feh-zoom executable and put it in directory in PATH. There is a help text,

$ feh-zoom -h
Help for feh-zoom by Nio Wiklund <nio.wiklund at gmail.com>

Usage:
 feh-zoom [--zoom <percent> [--position <+X+Y>]] <picture-1> [picture-2] [...]

Examples:

feh-zoom --zoom 200 picture.png
feh-zoom --zoom 50 --position +400+200 g*.jpg

    --zoom <percent>
        Zoom images by percent. Will create a correct window size automatically.
        . this option is modified in this shellscript compared to feh.
        
    --position <+X+Y>
        Position of the picture-window's top left corner
        (offset X pixels and Y pixels from the screen's top left cormer)
        . this is an option only for this shellscript, but not for feh.

    <picture-1> [picture-2] [...]
       . Specify at least one picture. Wild-card works, e.g. *.png
 
       . Switch to the next picture with 'q' (while you do it with -> in feh).
         Quit with 'qq' (press 'q' twice within one second).

       . The standard options for feh (for example --randomize) will fail
         because feh is called for one picture eash time in a for-loop, and
         no more options are passed.

If the first option is not --zoom, this shellscript passes control to feh
directly, so that all the standard options for feh will work.

General help for feh: man feh
Score:1
sy flag

Thank you, sir, for your help!

I see I should read the manual more carefully next time, but anyway am I positive that I have to use the following command to zoom my picture twice?

feh  --zoom 200 --geometry $(feh  -l pictorius.png |  awk '(NR==2) {print(($3*2)"x"($4*2));}') pictorius.png 

Honestly, it sounds like a bad joke. Or is there a simpler way?

sudodus avatar
jp flag
+1+1; You are welcome, and congratulations to a solution. You can make a function or a shellscript and get your own custom version of feh :-)
xerostomus avatar
sy flag
Are you kidding? :-)) Is there no simpler way???
sudodus avatar
jp flag
Haha :-) Well, maybe you can find another tool, that is better at zooming. Exactly how do you intend to use `feh`, for example, how automatic should it be? Would it be OK with some interacton? `eog` zooms with the scrolling wheel. I guess you can use the tools of ImageMagick to get something nice. - With `feh` you can drag a corner to get the size you want, then right-click and in the popup menu select 'freeze window size' and then 'autozoom'.
xerostomus avatar
sy flag
Well, it works now, but it is clumsy. I have a script to practice morse alphabet, so i want to display a table with code at some place of screen. Nothing important. Thanks for help anyway. :-)
sudodus avatar
jp flag
I was challenged by the problem to make `feh` zoom without specifying a fixed geometry (or fullscreen). So I made a shellscript that you can make executable and put in directory in PATH. See my edited answer.
xerostomus avatar
sy flag
Dear Mr. Wiklund, it is a true masterpiece! I can learn a lot on it, but it is still not simpler. :-)) Thank you. We must send it to feh GitHub, to improve it.
sudodus avatar
jp flag
I saw your mail to the feh developer. Let us hope for success :-)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.