irelephant [he/him]

Failing optimist, can code poorly.

🇵🇸 Saoirse don Phalastín! 🇵🇸
Previously @irelephant@lemm.ee.

  • 2 Posts
  • 2 Comments
Joined 8 months ago
cake
Cake day: June 4th, 2025

help-circle

  • The snippet that does this is:

    if site.enable_chan_image_filter:
                    # Do not allow fascist meme content
                    try:
                        if '.avif' in uploaded_file.filename:
                            import pillow_avif  # NOQA
                        image_text = pytesseract.image_to_string(Image.open(BytesIO(uploaded_file.read())).convert('L'))
                    except FileNotFoundError:
                        image_text = ''
                    except UnidentifiedImageError:
                        image_text = ''
    
                    if 'Anonymous' in image_text and (
                            'No.' in image_text or ' N0' in image_text):  # chan posts usually contain the text 'Anonymous' and ' No.12345'
                        self.image_file.errors.append(
                            "This image is an invalid file type.")  # deliberately misleading error message
                        current_user.reputation -= 1
                        db.session.commit()
                        return False
    

    (Link in the post body)