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 7646273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:09:55+00:00 2026-05-31T10:09:55+00:00

I’m having troubles cropping image. For me CICrop filter is not working properly. If

  • 0

I’m having troubles cropping image. For me CICrop filter is not working properly. If my CIVector x and y (origins) are 0 everything working fine (image is cropped from left bottom corner), image is cropped by my rectangle width and height, but if CIVector origins (x and y) aren’t 0 in my cropped image becomes space (because CICrop filter cropping from bottom left corner no matter what origins (x and y) are).

I’m cropping CIImage with rectangle, source:

CIVector *cropRect =[CIVector vectorWithX:150 Y:150 Z: 300 W: 300];

CIFilter *cropFilter = [CIFilter filterWithName:@"CICrop"];   

[cropFilter setValue:myCIImage forKey:@"inputImage"];
[cropFilter setValue:cropRect forKey:@"inputRectangle"];

CIImage *croppedImage = [cropFilter valueForKey:@"outputImage"];

Output Image with CIVector X 150 and Y 150: (I drawn the border for clarity)

enter image description here

Output Image with CIVector X 0 and Y 0:

enter image description here

Original Image:

enter image description here

What I’m doing wrong? Or is it supposed to do this?

  • 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-31T10:09:57+00:00Added an answer on May 31, 2026 at 10:09 am

    Are you sure the output image is the size you are expecting? How are you drawing the output image?

    The CICrop filter does not reduce the size of the original image, it just blanks out the content you don’t want.

    To get the result you want you probably need to just do this:

    [image drawAtPoint:NSZeroPoint fromRect:NSMakeRect(150, 150, 300, 300) operation:NSCompositeSourceOver fraction:1.0];
    

    If you want an actual CIImage as output rather than just drawing it, just do this:

    CIImage* croppedImage = [image imageByCroppingToRect:CGRectMake(150, 150, 300, 300)];
    
    //you also need to translate the origin   
    CIFilter* transform = [CIFilter filterWithName:@"CIAffineTransform"];
    NSAffineTransform* affineTransform = [NSAffineTransform transform];
    [affineTransform translateXBy:-150.0 yBy:-150.0];
    [transform setValue:affineTransform forKey:@"inputTransform"];
    [transform setValue:croppedImage forKey:@"inputImage"];
    CIImage* transformedImage = [transform valueForKey:@"outputImage"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.