Code Monkey home page Code Monkey logo

artwork-framer's Introduction

Artwork Framer

Embedding image files (.png, .jpg, etc.) into a 3D frame using Blender. It scales the frame according to the aspect ratio of each input image and exports the resulting model.

untitled

Requirements

  • Blender v3.x (tested on v3.2.2)

File Structure

  • input/: Folder containing images to be processed.
  • output/: Folder where processed models will be stored.
  • frame.blend: Blender file containing the 3D frame model.
  • artwork-framer.sh: Shell script that runs the Python script.
  • main.py: Python script that processes the images and exports the models.
  • src/exporters: Contains the exporters for different file formats (not all of them currently work correctly, if in doubt, default to GLTF).

Usage

There are two main ways to run the script: via the command line or inside Blender.

The command line method is preferred since it's the easiest to set up and use. The Blender method is useful if you want to make changes to the script and test them out.

Regardless, the script will process all images in the input/ directory and store the resulting models in the output/ directory (by default in GLTF format).

Currently, the format is hard-coded in the script. You can find it in the main.py file if you want to change it (CMD + F and Ctrl + F are your friends).

Running the Script via the Command Line (preferred)

Prerequisites

There are a couple of steps to make this all work.

  1. Find out your Blender path (check official Blender docs for instructions)
  2. Create .env, and set BLENDER_PATH to the path you found in step 1.
  3. You might need to make the script executable: chmod +x artwork-framer.sh

Running the Script

Once you're set-up, you can run the script.

./artwork-framer.sh

This will process all the images, and you should see the output models in the output/ directory.

--artwork_label <TEXT>

Add a label to the artwork 3D model. This will be displayed in the Blender scene.

./artwork-framer.sh --artwork_label "My Artwork"

Running the Script Inside Blender

  • Open frame.blend in Blender.
  • Open the main.py script in Blender's text editor.
  • Run the script.

Batch Processing

To run batch processing of images, simply place all images in the input/ directory before running the script. The script will process all images and store the output models in output/.

Changing the frame

If you want to change the frame, you can do so by opening the frame.blend file in Blender and making the changes you want.

The script works by moving the top vertices of the frame upwards to match the aspect ratio of the input image. This means that the frame object must be a rectangle, and you need to follow a couple of rules.

  • Keep the frame & picture objects named Frame & Picture respectively.

  • Keep the dimensions of the Picture object to 2 x 2 (the default). You can change the depth of the picture (Y axis), but the width and height must remain the same.

  • If you make any changes to the frame, you may need to reassign the vertices at the top of the frame to the Top Frame Edge vertex group.

Screenshot 2023-10-23 at 22 37 08 Screenshot 2023-10-23 at 22 37 02
  • If you make any changes to the picture, you may need to reassign the vertices at the top of the picture to the Top Picture Edge vertex group.
Screenshot 2023-10-23 at 22 35 00 Screenshot 2023-10-23 at 22 34 46

Contributing

Feel free to fork this repository or submit PRs for improvements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.