Created
February 6, 2026 21:31
-
-
Save julioea/234a6d4c8e55db3a81c957f46bfaafc5 to your computer and use it in GitHub Desktop.
Shellscript que cria um poster de filme a partir de uma imagem e um prompt de dados, criado pelo meu amigo abacaxis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Polaroid Movie Poster Generator 1.0 by abacaxis | |
| # Depende do pacote Imagemagick | |
| # Invoque o programa pelo comando "polaroid" | |
| # Insira os dados que ele te pedir | |
| # --- FILE INPUT --- | |
| PIC=$1 | |
| if [ -z "$PIC" ]; then | |
| echo "Usage: $0 <filename>" | |
| exit 1 | |
| fi | |
| NOME="${PIC%.*}" | |
| # --- DATA INPUT --- | |
| # Prompts for polaroid metadata. | |
| echo "--- Polaroid Movie Poster Generator 1.0 ---" | |
| read -p "Movie Title: " TITLE | |
| read -p "Release Year: " YEAR | |
| read -p "Director: " DIRECTOR | |
| read -p "Main Star: " STAR | |
| # --- COLOR EXTRACTION --- | |
| # Extracts 8 dominant colors for the bottom bar. | |
| echo "Extracting the 8 most dominant colors pallete..." | |
| COLORS=$(magick "$PIC" -colors 8 -unique-colors txt:- | grep -oh "#[A-F0-9]\{6\}" | head -n 8) | |
| # --- COORDINATES & SIZES --- | |
| # Define positions for the color blocks. | |
| draw_command="" | |
| x_pos=50 | |
| y_pos=1350 | |
| block_width=112 | |
| block_height=60 | |
| for hex in $COLORS; do | |
| draw_command="$draw_command fill '$hex' rectangle $x_pos,$y_pos $((x_pos + block_width)),$((y_pos + block_height))" | |
| x_pos=$((x_pos + block_width)) | |
| done | |
| echo "Rendering Polaroid..." | |
| # --- IMAGE RENDERING --- | |
| # Calcula a largura do título para saber onde posicionar o ano | |
| TITLE_SIZE=60 | |
| YEAR_SIZE=30 | |
| TITLE_WIDTH=$(magick -font "Liberation-Sans-Bold" -pointsize $TITLE_SIZE label:"${TITLE}" -format "%w" info: | tr -d '% ') | |
| # Define a posição X do Ano (Margem 50 + Largura do Título + 5px de espaço) | |
| YEAR_X=$((50 + TITLE_WIDTH + 5)) | |
| magick -size 1000x1500 xc:#f5f5f5 \ | |
| \( "$PIC" -resize 900x900^ -gravity center -extent 900x900 \) \ | |
| -gravity north -geometry +0+50 -composite \ | |
| -fill "#222222" \ | |
| -gravity SouthWest \ | |
| -font "Liberation-Sans-Bold" -pointsize $TITLE_SIZE -annotate +50+420 "${TITLE}" \ | |
| -font "Liberation-Sans" -pointsize $YEAR_SIZE -annotate +${YEAR_X}+428 "($YEAR)" \ | |
| -font "Liberation-Sans" -pointsize 40 -annotate +50+340 "Direção: $DIRECTOR" \ | |
| -font "Liberation-Sans" -pointsize 40 -annotate +50+280 "Estrela: $STAR" \ | |
| -gravity North -draw "$draw_command" \ | |
| -depth 8 -quality 90 png8:"$NOME-poster.png" | |
| echo "$TITLE rendered" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obrigado pelo apoio amigo.