[solved]imagerotateandresize

Community Driven Extensions Project
azadeh
Posts: 54
Joined: 01 May 2012, 10:42

14 May 2012, 08:54

hi
i'm new in primefaces extension
i use primefaces extension for rotate and resize my image. my image is a picture file from my system
but i want to save this image after resize or rotate on same image in same location .
i don't know how to do it
please help
Last edited by azadeh on 16 Jul 2013, 11:33, edited 2 times in total.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

14 May 2012, 09:30

You can't without more code :)
You must catch the resize and rotate events on server side and save the values in a viewScoped bean.
Then (if you click on a save button or else) you must rotate/resize your image via a java image api. We've done it via BufferedImage.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

azadeh
Posts: 54
Joined: 01 May 2012, 10:42

14 May 2012, 10:02

thanks for your reply
can you give me an example with java code to do it??????
thanks

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

14 May 2012, 11:11

search for BufferedImage in google, it's easy.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

azadeh
Posts: 54
Joined: 01 May 2012, 10:42

16 May 2012, 10:17

i searched in google and find many example
but i cant understand how to use it
for example in my xhtml page how call my servlet class that has buffredimage or
in my java class how get rotated or scaled image from xhtml page and .....
please help me
thanks

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

16 May 2012, 10:30

Code: Select all

<pe:imageRotateAndResize id="rotateAndResize" for="myImage" widgetVar="rotateAndResizeWidget">  
    <p:ajax event="rotate" listener="#{imageController.rotateListener}" update="growl"/>  
    <p:ajax event="resize" listener="#{imageController.resizeListener}" update="growl"/>  
</pe:imageRotateAndResize>  

<p:commandLink actionListener="#{imageController.saveImageToDisk}"/>

Code: Select all

@Named or @ManagedBean
@ViewScoped
public class ImageController implements Serializable {

    private int rotationDegree;
    private int height;
    private int width;

    public void rotateListener(final RotateEvent e) {  
        this.rotationDegree= e.getDegree();
    }  
  
    public void resizeListener(final ResizeEvent e) {  
       this.height = e.getHeight();
       this.width = e.getWidth();
    }  

   public void saveImageToDisk() {
      //load your iamge wiht bufferedImage
      //resize and rotate it with rotationDegree, height & width
      //save it

    }
}
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

azadeh
Posts: 54
Joined: 01 May 2012, 10:42

19 May 2012, 07:36

thanks for reply
but when click on scale button give me this error:
method not found: resizeListener(org.primefaces.extensions.event.ResizeEvent)
what is my problem???????

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

19 May 2012, 11:35

Don't know, please look at the showcase.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

19 May 2012, 13:14

As i can see, it works in our app. Please check your bean and method signature. ResizeEvent must be from extensions, not from PF.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

azadeh
Posts: 54
Joined: 01 May 2012, 10:42

20 May 2012, 05:49

yes that's right
thank you
i solved it with your help
i used pf istead of extension

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests