I am trying to find a way to create a custom image field that can take extra crop information.
A custom image field that creates two db columns one for image path the other is for image's crop information (it will be dynamic top, left, width, height informations that user can set via a js component ).
Can a model field be customized to create and validate two db columns? Or is this a wrong way to go?
Django model fields can only map to one database column, so until they provide an easy solution it's not possible.
You can take a look at this workaround.
Anyway what you can do is override the model save method and use PIL for example to crop the image and set it equal to the cropped image field.
To override an model field, it's pretty simple and easy and you can pass extra parameter. Check the documentation everything is well explained.
Related
I'm working on a stream overlay that extracts information out of a game (flight simulator) and displays it on the screen. Right now I'm using Qt in conjunction with a *.html to render the overlay. It is all working really well, however I wanted to add some customization options for the users of my overlay software and I figured the best way would be to render the Overlay in QML.
The main part of the overlay is a row that contains around 8 "elements" that display the relevant data.
One thing that should be customized is the order of the elements in the row. But I really have no idea how to implement this feature. I've seen a few posts and tutorials on how to customize the order in a View using the DelegateModel. However right now it's not a view but QML Components inserted in a RowLayout due to the fact that they are all different components (e.g. some of the images are actually animated for which I'm using a component that uses Canvas2D to draw the images). I guess I could figure out a way to store those elements in a model using the Loader Component to display the content in QML. But even then I'm not entirely sure how to store and restore the order of the elements. As far as I can tell the DelegateModel only changes the View and not the underlying model.
Any suggestion or best practice to accomplish my goal would be highly appreciated.
I am using tableview to display a list of items
e.g.
list =
[
{name='bob',
description='really long description that can be multiple rows',
image='an image from my server',
},
...
]
the above is just an example. I got my data from my server, including images of variable sizes. My question is how do I display the correct row size(height) once I got image from the server. I understand that I can wait until all data and image has been downloaded from server. Then precompute the height. But I want to be able to display the text first (as texts are more likely to be firstly downloaded), then once there is an image in it, I download it again. After the image is downloaded, I want to resize the row height. How can I do that?
Create a multi-line display.newText() of the width you expect to put in the table view. When the object is created, grab it's height and then remove the object. Use that height + some padding for the row height. There may be performance issues with this, so as an alternate, keep the text object and pass it in as a parameter when you create the row.
I am new to codename one and I have tried for one and half day to fix my issue of,
a list with background image in each row.
Let me explain, I am having a list with some items(entries), I created renderer and name it appropriately. I set background correctly which is reflecting in designer (see image)
but when I run it on simulator/device , all formatting and designs are just invisible..!! (see red arrow pointing to simulator in image)
anyone have any idea ? why this is happening ?
Thanks,
Akash
It seems you didn't set the background correctly in the designer. Since the list items in the model within the designer are strings the renderer entries don't get overriden and so you see a separate UI.
To reproduce the issue in the designer click the items entry in the list property, remove everything and add a sample key/value hashtable pair. You would see all your design entries disappearing.
This might help you understand how to customize images and backgrounds here: http://www.codenameone.com/3/post/2013/12/deeper-in-the-renderer.html
I have a page that displays a series of available items for the public to purchase. Each of these items displays the image for the related product. My cfimage code is made to scale-to-fit the stored image.
Normally the displayed results will all show different products and their corresponding images. However, when I use the code all of my products show the same image, instead of showing the images that are linked to each product via a file path stored in the database. Is there a way to set the "name="myImage" dynamically so that each image will display and scale properly?
I want to get the cover of an album with an specific height and width, or, in fact, a square thumbnail generated by default in the Facebook Api.
I only get the album ID and its cover ID.
If I use $facebook->api('/'.$cover_id) then the API method returns me only 6 sizes of this image, but I want to get a thumbnail.
This is possible?
Try This may be this help full for you
https://developers.facebook.com/docs/reference/api/photo/