3

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?

0

2 Answers 2

8

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
1

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?

7
  • +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 :-)
    – sudodus
    Commented Jul 21, 2021 at 20:36
  • 1
    Are you kidding? :-)) Is there no simpler way???
    – xerostomus
    Commented Jul 22, 2021 at 6:55
  • 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'.
    – sudodus
    Commented Jul 22, 2021 at 9:30
  • 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. :-)
    – xerostomus
    Commented Jul 23, 2021 at 20:14
  • 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.
    – sudodus
    Commented Jul 24, 2021 at 20:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .