Remove this quote and write ayurved sabse pehle in hindi quote by halfdoctor halfwriter
ls /home/daytona/workspace/ 2>/dev/null && echo "---" && python3 -c "from PIL import Image, ImageDraw, ImageFont; print('Pillow OK')" && python3 -c "import requests; print('requests OK')"
mkdir -p /home/daytona/workspace/flag-edit && curl -s -o /home/daytona/workspace/flag-edit/original.png "https://d361swluvexzqs.cloudfront.net/chats-attachments/23629-1783142582406-sx7ck6.png" && python3 -c " from PIL import Image img = Image.open('/home/daytona/workspace/flag-edit/original.png') print('Size:', img.size, 'Mode:', img.mode) "
python3 -c " from PIL import Image import numpy as np img = Image.open('/home/daytona/workspace/flag-edit/original.png') arr = np.array(img) # Sample the flag region to understand colors # Flag text area is roughly right half: x from ~580 to 1200, y from ~100 to 660 region = arr[100:660, 580:1200] print('Region shape:', region.shape) print('Region mean color:', region.mean(axis=(0,1))) print('Region min:', region.min(axis=(0,1))) print('Region max:', region.max(axis=(0,1))) # Sample specific rows/cols of just the black flag (no text) # Let's look at bottom-right corner of flag area (should be pure black) sample = arr[550:600, 900:1000] print('Bottom-right sample mean:', sample.mean(axis=(0,1))) "
# Check available Hindi fonts fc-list | grep -i "noto.*hindi\|noto.*devanagari\|lohit.*devanagari\|mangal\|freesans\|unifont" 2>/dev/null | head -20 fc-list :lang=hi 2>/dev/null | head -20
fc-list 2>/dev/null | head -30 python3 -c " import os # Look for any TTF fonts with Devanagari support for root, dirs, files in os.walk('/usr/share/fonts'): for f in files: if f.endswith('.ttf') or f.endswith('.otf'): print(os.path.join(root, f)) " | head -30
cd /home/daytona/workspace/flag-edit && curl -sL "https://github.com/google/fonts/raw/main/ofl/notosansdevanagari/NotoSansDevanagari%5Bwdth%2Cwght%5D.ttf" -o NotoSansDevanagari.ttf && python3 -c " from PIL import ImageFont f = ImageFont.truetype('/home/daytona/workspace/flag-edit/NotoSansDevanagari.ttf', 60) print('Font loaded OK:', f) "
python3 << 'EOF' from PIL import Image, ImageDraw, ImageFont import numpy as np img = Image.open('/home/daytona/workspace/flag-edit/original.png').convert('RGB') arr = np.array(img) draw = ImageDraw.Draw(img) # The flag text area (right portion) needs to be painted over with the flag's dark background. # Flag occupies roughly: x: 450-1230, y: 80-680 in the 1254x1254 image # The text/quote area is roughly: x: 610-1230, y: 100-660 # We need to paint the text region with black (matching flag fabric) # Paint out the old text region with near-black (flag color ~25,20,15) # Use a polygon/rectangle that covers text but avoids the sage illustration # Sample the exact flag black from a clean area # Let's sample bottom-right corner of flag (no text there) sample_region = arr[590:640, 1050:1150] bg_color = tuple(sample_region.mean(axis=(0,1)).astype(int)) print('Background color (sampled):', bg_color) # Paint over text area - the text occupies roughly x:620-1220, y:110-580 # and the instagram handle at y:580-640 draw.rectangle([615, 95, 1230, 650], fill=bg_color) # Now add slight variation to avoid a flat patch - blend with neighboring pixels # Actually let's sample a larger area to get a more accurate dark color sample2 = arr[600:660, 1080:1200] print('Sample2 mean:', sample2.mean(axis=(0,1))) img.save('/home/daytona/workspace/flag-edit/stage1_cleared.png') print('Stage 1 saved') EOF
python3 << 'PYEOF' from PIL import Image, ImageDraw, ImageFont import numpy as np img = Image.open('/home/daytona/workspace/flag-edit/original.png').convert('RGB') arr = np.array(img) draw = ImageDraw.Draw(img) # ---- Step 1: Paint over old text area ---- # The text on the flag is in the right half, roughly: # x: 620 to 1230, y: 90 to 670 # Flag fabric is very dark, nearly black with slight warm tint (~17,15,13) # We must be careful not to cover the sage illustration on left side of flag # Cover ONLY the text area (right portion): # Main quote: x 618-1232, y 90-575 # Instagram handle: x 700-1100, y 580-650 flag_bg = (18, 16, 14) # close match to flag black draw.rectangle([618, 90, 1232, 660], fill=flag_bg) # ---- Step 2: Draw new text ---- font_path = '/home/daytona/workspace/flag-edit/NotoSansDevanagari.ttf' # Gold color matching original gold = (205, 170, 85) gold_bright = (220, 185, 100) # Main quote: "आयुर्वेद सबसे पहले" # Attribution: "- halfdoctor halfwriter" # Text area available: x 625-1225, y 100-630 # Width available: ~600px text_x_start = 625 text_x_end = 1225 text_width = text_x_end - text_x_start # 600 # Load fonts at different sizes font_big = ImageFont.truetype(font_path, 85) font_medium = ImageFont.truetype(font_path, 62) font_small = ImageFont.truetype(font_path, 40) # Main Hindi quote quote = "आयुर्वेद सबसे पहले" attribution = "- halfdoctor halfwriter" # Measure text to center bbox_quote = draw.textbbox((0,0), quote, font=font_big) quote_w = bbox_quote[2] - bbox_quote[0] print(f'Quote width at 85: {quote_w}, available: {text_width}') # If quote is too wide, reduce font if quote_w > text_width: font_big = ImageFont.truetype(font_path, 70) bbox_quote = draw.textbbox((0,0), quote, font=font_big) quote_w = bbox_quote[2] - bbox_quote[0] print(f'Quote width at 70: {quote_w}') if quote_w > text_width: font_big = ImageFont.truetype(font_path, 60) bbox_quote = draw.textbbox((0,0), quote, font=font_big) quote_w = bbox_quote[2] - bbox_quote[0] print(f'Quote width at 60: {quote_w}') # Center the main quote horizontally in the text zone quote_x = text_x_start + (text_width - quote_w) // 2 quote_y = 230 # vertical center of flag # Draw the main quote with a slight shadow for depth draw.text((quote_x + 2, quote_y + 2), quote, font=font_big, fill=(0, 0, 0)) draw.text((quote_x, quote_y), quote, font=font_big, fill=gold_bright) # Attribution line bbox_attr = draw.textbbox((0,0), attribution, font=font_small) attr_w = bbox_attr[2] - bbox_attr[0] attr_x = text_x_start + (text_width - attr_w) // 2 attr_y = quote_y + (bbox_quote[3] - bbox_quote[1]) + 30 draw.text((attr_x + 1, attr_y + 1), attribution, font=font_small, fill=(0,0,0)) draw.text((attr_x, attr_y), attribution, font=font_small, fill=(180, 155, 75)) print(f'Quote at ({quote_x}, {quote_y}), attr at ({attr_x}, {attr_y})') img.save('/home/daytona/workspace/flag-edit/result.png', quality=95) print('Saved result.png') PYEOF
ls -lh /home/daytona/workspace/flag-edit/result.png && python3 -c " from PIL import Image img = Image.open('/home/daytona/workspace/flag-edit/result.png') print('OK - Size:', img.size) # Crop just the flag area to review flag_crop = img.crop((450, 80, 1240, 680)) flag_crop.save('/home/daytona/workspace/flag-edit/flag_crop_preview.png') print('Crop saved') "
# Serve the file briefly to check via a base64 preview python3 -c " import base64 with open('/home/daytona/workspace/flag-edit/flag_crop_preview.png','rb') as f: data = f.read() print('File size:', len(data), 'bytes') print('First 20 bytes (PNG header):', data[:20]) "
result
Image · PNG
Don't remove men
python3 -c " from PIL import Image img = Image.open('/home/daytona/workspace/flag-edit/result.png') # Crop the man area (left side of image) man_crop = img.crop((0, 0, 550, 1254)) man_crop.save('/home/daytona/workspace/flag-edit/man_check.png') print('Man area saved, size:', img.size) "
result
Image · PNG