Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 386337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:34:01+00:00 2026-05-12T15:34:01+00:00

from PIL import Image im = Image.open(f) #the size is 500×350 box = (0,0,100,100)

  • 0
from PIL import Image

im = Image.open(f)  #the size is 500x350
box = (0,0,100,100)
kay = im.crop(box)

It seems like there’s nothing wrong with this, right?

That last line will result in an error and won’t continue, but I don’t know what the error is because it’s AJAX and I can’t debug ATM.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:34:01+00:00Added an answer on May 12, 2026 at 3:34 pm

    If your controller is dealing with strings because the crop data is coming in via an ajax GET, it might be worth trying to make them into integers before applying the crop. Example from my terminal…

    Trinity:~ kelvin$ python
    Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) 
    [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from PIL import Image
    >>> f = open("happy.jpg")
    >>> im = Image.open(f)
    >>> box = (0,0,100,100)
    >>> kay = im.crop(box)
    >>> kay
    <PIL.Image._ImageCrop instance at 0xb1ea80>
    >>> bad_box = ("0","0","100","100")
    >>> nkay = im.crop(bad_box)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/Image.py", line 742, in crop
        return _ImageCrop(self, box)
      File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/Image.py", line 1657, in __init__
        self.size = x1-x0, y1-y0
    TypeError: unsupported operand type(s) for -: 'str' and 'str'
    >>> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using PIL. from PIL import Image try: im = Image.open(filename) #
from PIL import Image import webbrowser, aggdraw im = Image.open('Background.png') # Drawing cross on
Scripts like that: from PIL import Image, ImageOps img = Image.open('1.JPG') thumb = ImageOps.fit(img,
from PIL import Image img = Image.open('1.png') img.save('2.png') The first image has a transparent
I have created this program: from PIL import Image, ImageDraw a = Image.open(r'C:\Users\damian\Desktop\a.png') draw
Consider the following code: from PIL import Image, ImageDraw, ImageFont def addText(img, lTxt): FONT_SIZE
I have some strange problem with PIL not resizing the image. from PIL import
from Tkinter import * import socket, sys from PIL import Image, ImageTk root =
please consider this reproducible example: from PIL import Image import numpy as np import
#import statements from Tkinter import * import tkMessageBox import tkFont from PIL import ImageTk,Image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.