Skip to content

EkanshdeepGupta/infinite-recursive-image

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

infinite-recursive-image

A script to create the Droste effect with any image. Has two modes -- orthogonal mode (-o) for rectangular boxes, and skew mode (-s) for skewed boxes.

Usage

Run:

$ git clone github.com/EkanshdeepGupta/infinite-recursive-image
$ cd ./infinite-recursive-image
$ python ./nested_photo.py -h
    usage: nested_photo.py [-h] [-o | -s] [-n COUNT] filename dimensions

    positional arguments:
      filename              the filename of the image to be processed.
      dimensions            the pixel dimensions of the box to create the effect. In orthogonal mode,
                            the dimensions have to be given as "x1,y1,x2,y2". In skew mode, dimensions
                            have to be given as "(x1,y1),(x2,y2),(x3,y3),(x4,y4)"

    optional arguments:
      -h, --help            show this help message and exit
      -o, --orthogonal      flag used to run the script on an orthogonally rectangular box. Defaults
                            to orthogonal mode.
      -s, --skew            flag used to run the script on a non orthogonally rectangular box.
      -n COUNT, --count COUNT
                            number of times to recurse. Defaults to 10.

For orthogonal mode, the dimensions can be given as a comma separated string of four numbers, which denote the pixel coordinates of the left, top, right, bottom edges respectively, of the box on which to generate the Droste effect. Since orthogonal mode only works on orthogonal rectangles, only the edges can be specified. For non-rectangular boxes, use skew mode with the -s flag. In orthogonal mode, the image is cropped accordingly to maintain the aspect ratio with the rectangular box.

For skew mode, the dimensions can be given as a string of four 2-tuples of numbers, which denote the pixel coordinates of the top-left, top-right, bottom-right, bottom-left corners respectively, of the box on which to generate the Droste effect. In skew mode, the perspective shift effect is used to make the image fit the dimensions given.

The pixel coordinates for dimensions can be found using any photo-editing software like GIMP or Adobe Photoshop.

Examples

Get the outputs stored in ./examples as follows:

Orthogonal mode:

test.webp

$ python nested_photo.py ./examples/modern-tv-cabinet.jpg "552,238,1049,540"

test-output

living-room-tv

$ python nested_photo.py ./examples/gray-wooden-sideboard.jpg "721,217,1217,550"

living-room-tv

Skew mode

$ python nested_photo.py ./examples/black-white.jpg -s "(246,312),(889,456),(887,826),(250,839)"

$ python nested_photo.py ./examples/living-room.jpg -s "(450,1020),(1196,1036),(1197,1430),(449,1476)"

$ python nested_photo.py "./examples/seats.jpg" -s "(1231,281), (2357,265), (2367,1009), (1244,1025)"

Photo Credits

  • Modern TV Cabinet - Photo by MAX 3D Design from Shutterstock.
  • Gray Wooden Sideboard - Photo from Pexels.
  • Black White - Photo by Sidekix Media on Unsplash.
  • Living Room - Photo by Jean van der Meulen from Pexels.
  • Seats - Photo by Simon Maris from FreeImages.

About

A script to create the Droste effect with any image.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages