Code Monkey home page Code Monkey logo

Comments (4)

a-axton avatar a-axton commented on June 3, 2024

I was having issues with this as well. What worked for me was setting the x and y option instead of using the defaults and make sure that neither the width or height the same as the original (subtract 1 if it's the same). You also need to count for the pixel density of the images in the crop dimensions which you can get with Ti.Platform.displayCaps.logicalDensityFactor. What worked for me (was changing image ratio from 4:3 to 16:9):

image = ImageFactory.imageAsCropped(image, {
    x: 0,
    y: 0,
    width: ((image.height*density)/1.777778)-1,
    height: (image.height*density)-1
  });

from ti.imagefactory.

designbymind avatar designbymind commented on June 3, 2024

Hi @a-axton,

Thanks for the above explanation & example code!

I'm still having an issue getting the imageAsCropped method to output my desired result. Since you've been able to figure out how to return what you needed from the module, I figured I'd reach out & ask for a little help.

My current result outputs a similar result to @NagarjunaReddy's, being zoomed, off center, blurred and/or stretched/compacted...

Here's what I'm looking to do:

  1. Take a photo with the camera (fullscreen portrait device height & device width)
  2. Crop the returned photo (e.media) to be square (width = device width & height = device width)
  3. Populate ImageView with cropped photo from the actions above

Here's an image to give you a visual:

  • The camera being fullscreen but the returned (and cropped) photo being centered and square
    image

Let me know if you need more info & any help is much appreciated!

ยท Jason

from ti.imagefactory.

hansemannn avatar hansemannn commented on June 3, 2024

@designbymind Is this resolved by now? I would suggest to use the center points and crop it from there using the specified width and height. That worked for me in the past. Thx!

from ti.imagefactory.

designbymind avatar designbymind commented on June 3, 2024

Hey @hansemannn - it's been awhile since I tried using the imageFactory cropping method as I'd found an alternative solution at the time. I even tried using the method you recommended above with no success. However, since having an additional (commonJS) module for cropping is unnecessary overhead if the built-in cropping methods of imageFactory work as expected, I'd be happy to test that out. I'm currently working with the camera for a new app & as soon as I get to that part of the development stage, I'll report back with my findings. Thanks man!

from ti.imagefactory.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.