Export bounding box only

Posted over 8 years ago by Jaap de Wit

Post a topic
  • Topic is Locked
Implemented
Jaap de Wit
Jaap de Wit

Hi,


I really would like to see the export functions to be changed. Currently the entire design area is being exported and I only want to export the items within the bounding box. All my products use the same bounding box.


See screenshot. The door is the area where the design is, the doorframe is the bounding box. When exporting the order design from WooCommerce I only want the door including all layers to be exported, not the background area.


Please include this in a next version.


Cheers,
Jaap

19 Votes


57 Comments

Sorted by
Rafael D

Rafael D posted over 8 years ago Admin

You can easily remove the layers you do not need in the order viewer and then export it.

0 Votes

P

Paulo Carrasco posted over 8 years ago


Hi. 


Of course you can delete layers, but if you have 500 orders to process... that's a lot of manual labour! And prone to make mistakes! Automation is the best way to avoid production errors. 


And why does the plugin export the ENTIRE stage if we define a bounding box so that we can limit the users drawing area? 

You can have a Stage with 1000 by 1000 pixels with a beautiful background, but have only a 500 by 500 pixels drawing area! Why do you have to export THE ENTIRE STAGE for production?? It makes no sense! Why? Because after the export operation the store operator has to edit the EVERY file in photoshop, crop out the 500 by 500 pixels from the image for printing production! 


And now Imagine that with 3 initial stage layers, like your iPhone cover example, that serve only so that the user has a visual guidance while drawing inside a bounding box that will contain the final drawing for production. You will not print out those 3 initial layers! You only want the final user drawing. 


Now imagine to process 500 orders, and having to remove 3 layers in each order!! Thats 1500 layers you have to remove, one by one!!  And manually crop 500 images, one by one after export! Try that yourself. use the iPhone cover example, try to draw a multi-layer cover for yourself, and then try to process that order, printing the final drawing in your printer WITHOUT the initial 3 layers and only the bounding box area!


Your plugin is great for online drawing pretty Pinterest images, good for sharing in social networks by the user, but regarding to the store owner labour, and production wise, your plugin is not workflow optimized! You would get A LOT of happy plugin customers, and increase your sales, by allowing to automate some repetitive steps! You have to think that your direct clients are companies that do some kind of production!


How can you improve your plugin?


  • create a "NO EXPORT" flag in the Product Builders Layers, and respect that flag when exporting the final image
  • Export only whats inside of the bounding box, clipping out the rest of the STAGE. For printing production we need a good hires image
  • Create a "Save as default settings" in the export options, so that you don't have to type the DPI and the scale factor FOR EVERY ORDER :(


Are you creating a online drawing tool, or a excellent production tool?


Best regards,


Paulo Carrasco


0 Votes

A

Adrienne Leverette posted over 8 years ago

Hi,


I had the same problem. I didn't want to include the entire stage area in the exported image file.  I managed to solve the problem by adding the function below to the js file. You define the element that you want to use as the bounding box. It returns the dataURL of the cropped image. Then I save the file to my server using an ajax call. 


Honestly, I don't know much about Javascript and jQuery so this might not be the best way to go about it. But it works great for me. I am using this on the jQuery version of the plugin, but it should work for WooCommerce too because I believe they use the same js file. You'd probably need to edit a template file to call the function. 


this.getCroppedImage = function(format, backgroundColor, multiplier) {

    instance.deselectElement();

    instance.currentViewInstance.stage.setDimensions({

        width: instance.currentViewInstance.options.stageWidth,

        height: instance.currentViewInstance.options.stageHeight

    }).setZoom(1);

    var boundingObj = instance.getElementByTitle('Door'); // Title of the element that will be used as the bounding box. Everything outside of this element will be cropped out

    var myGroup = new fabric.Group();

    // ensure originX/Y 'center' is being used, as text uses left/top by default.

    myGroup.set({

        originX: 'center',

        originY: 'center'

    });

    // clone objects and put them in new group

    var i = instance.currentViewInstance.stage.getObjects().length;

    while (i--) {

        var clone = fabric.util.object.clone(instance.currentViewInstance.stage.item(i));

        clone.title = clone.title + 'clone';

        myGroup.addWithUpdate(clone).setCoords();

        clone.sendToBack;

    }

    instance.currentViewInstance.stage.add(myGroup);

    myGroup.sendToBack();

    instance.currentViewInstance.stage.renderAll();

    if (typeof boundingObj !== 'undefined') {

        var boundingRectangle = boundingObj.getBoundingRect();

    } else {

        // get bounding rect for new group

        var i = instance.currentViewInstance.stage.getObjects().length;

        while (--i) {

            var objType = instance.currentViewInstance.stage.item(i).type;

            if (objType == 'group') {

                var boundingRectangle = instance.currentViewInstance.stage.item(i).getBoundingRect();

            }

        }

    }

    var dataURL = instance.currentViewInstance.stage.toDataURL({

        format: 'png',

        multiplier: 4,

        left: boundingRectangle.left,

        top: boundingRectangle.top,

        width: boundingRectangle.width,

        height: boundingRectangle.height,

        backgroundColor: 'transparent'

    });

    instance.currentViewInstance.stage.remove(myGroup);

    return dataURL; //returns cropped image

};

0 Votes

k

kimberly Ireland posted over 8 years ago

I need this exact same ability. I need to export only what is within the bounding box.
Can someone smarter than me tell me where to add this code for the wordpress plugin?

thank you



 

0 Votes

J

Joao Figueiredo posted over 8 years ago

This is a great idea! Today's industry has a very high tempo and automation is vital! At the same time one must offer the best good looking products to the customer. In this case it means that we need to offer the product in a context (for instance, a canvas in a living room) so that the customer has a "hands on" experience. To remove these extra elements that we use for sales increasing in every single order is just madness!


I hope this function gets implemented and I look forward for it!

0 Votes

J

Joao Figueiredo posted about 8 years ago

Adrienne Leverette can you please tell us where you implemented your solution?

 

0 Votes

A

Adrienne Leverette posted about 8 years ago

Hi! My implementation is below. I am not an expert in jQuery or javascript, so this may not be the best way to go about it, but it works for me!

I'm using the jQuery plugin version of FPD (in a Magento based store), but I believe it should work with the Wordpress and Opencart versions too because the FancyProductDesigner.js file appears to be the same with all of the FPD plugins.

My modification will export only the elements that are inside of the bounding object that you specify in the this.getCroppedImage function. The cropped image is downloaded when you click the download icon in the designer. Be sure to enable the 'download' action in the plugin options so that the download icon will appear in the designer.

Don't forget to change the name of the element you will be using as the bounding object in the this.getCroppedImage function below!

I hope this helps you!

***Step 1*** Open FancyProductDesigner.js. Find the following function (starts at line 6307 in FPD 4.1):

  

//download png, jpeg or pdf
 this.downloadFile = function(type) {

  if(type === 'jpeg' || type === 'png') {

   var a = document.createElement('a'),
    background = type === 'jpeg' ? '#fff' : 'transparent';

   if (typeof a.download !== 'undefined') {

    fpdInstance.getProductDataURL(function(dataURL) {

     fpdInstance.$container.find('.fpd-download-anchor').attr('href', dataURL)
     .attr('download', 'Product.'+type+'')[0].click();

    }, background, {format: type})

   }

 

   

***CHANGE it to:

this.downloadFile = function(type) {
  //Fix for downloading large DataURI's in Chrome
  var dataURI = fpdInstance.getCroppedImage();
  var file = fpdInstance.dataURItoBlob(dataURI); 
  var url = URL.createObjectURL(file);
  
  if(type === 'jpeg' || type === 'png') {

   var a = document.createElement('a');
     fpdInstance.$container.find('.fpd-download-anchor').attr('href', url)
     .attr('download', 'Product.jpg')[0].click();	

      }
   } 


***Step 2*** in FancyProductDesigner.js, find "_initialize();" at the end of the file. (it's after the "this.setDimensions" function. Line 9959 in FPD 4.1 ) 

***ADD the following ABOVE the "_intialize();" line (after the "this.setDimensions" function)

//Fix for downloading large DataURIs in Chrome
this.dataURItoBlob = function(dataURI) {
    // convert base64/URLEncoded data component to raw binary data held in a string
    var byteString;
    if (dataURI.split(',')[0].indexOf('base64') >= 0)
        byteString = atob(dataURI.split(',')[1]);
    else
        byteString = unescape(dataURI.split(',')[1]);

    // separate out the mime component
    var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];

    // write the bytes of the string to a typed array
    var ia = new Uint8Array(byteString.length);
    for (var i = 0; i < byteString.length; i++) {
        ia[i] = byteString.charCodeAt(i);
    }

    return new Blob([ia], {type:mimeString});
};

this.getCroppedImage = function(format, backgroundColor, multiplier) {
    instance.deselectElement();
    instance.currentViewInstance.stage.setDimensions({
        width: instance.currentViewInstance.options.stageWidth,
        height: instance.currentViewInstance.options.stageHeight
    }).setZoom(1);
 // Title of the element that will be used as the bounding box. Everything outside of this element will be cropped out
    var boundingObj = instance.getElementByTitle('Door'); 
    var myGroup = new fabric.Group();
    // ensure originX/Y 'center' is being used, as text uses left/top by default.
    myGroup.set({
        originX: 'center',
        originY: 'center'
    });
    // clone objects and put them in new group
    var i = instance.currentViewInstance.stage.getObjects().length;
    while (i--) {
        var clone = fabric.util.object.clone(instance.currentViewInstance.stage.item(i));
        clone.title = clone.title + 'clone';
        myGroup.addWithUpdate(clone).setCoords();
        clone.sendToBack;
    }
    instance.currentViewInstance.stage.add(myGroup);
    myGroup.sendToBack();
    instance.currentViewInstance.stage.renderAll();
    if (typeof boundingObj !== 'undefined') {
        var boundingRectangle = boundingObj.getBoundingRect();
    } else {
        // get bounding rect for new group
        var i = instance.currentViewInstance.stage.getObjects().length;
        while (--i) {
            var objType = instance.currentViewInstance.stage.item(i).type;
            if (objType == 'group') {
                var boundingRectangle = instance.currentViewInstance.stage.item(i).getBoundingRect();
            }
        }
    }
    var dataURL = instance.currentViewInstance.stage.toDataURL({
        format: 'png',
        multiplier: 4,
        left: boundingRectangle.left,
        top: boundingRectangle.top,
        width: boundingRectangle.width,
        height: boundingRectangle.height,
        backgroundColor: 'transparent'
    });
    instance.currentViewInstance.stage.remove(myGroup);
    //returns cropped image
 return dataURL; 
};

 



0 Votes

U

Umberto Enzo posted about 8 years ago

On a similar note and to further rationalise the work flow for certain situations I suggest adding a direct link to the original image uploaded by the customer in export options.

When your product doesn't involve adding text or modifying the image as such, but just positioning it within a frame (bounding box) - for instance with a canvas print. The original, unprocessed image is what you will work with.

Yes, you will need the bounding box export as a guide as you create the canvas, but you won't use that to create the canvas. Currently exporting 'single elements' only gives access to the version of the image that has been whizzed by FPD - even if the export settings are use original size and no bounding box it is the image that lives in  /wp-content/fancy_products_orders/images/ not the original which lives in /wp-content/uploads/fancy-product-uploads/ that is exported and seems to be a huge file compared to the original.

Currently accessing /wp-content/uploads/fancy-product-uploads/ is a problem for the non-technical shop owner (like my current client). It's one of the things preventing me from using this plugin in production. 

Surely it is not a major modification to add this to export options?

Thank you

0 Votes

J

Joao Figueiredo posted about 8 years ago

"The cropped image is downloaded when you click the download icon in the designer." - I am afraid I will not be able to implement your solution since at this moment it is not an option for us to make that option available for the user. Still, it is a great help! Thank you very much! :)

 

0 Votes

P

Pascal Kailitz posted about 8 years ago

Hello Adrienne,



I tried your javascript on my woocommerce store, but it doesn't work. I tried to export a pdf, png, jpg. Nothing works. Which kind of export file do you use?

And I use as bounding box the item "Door" and enabled it everywhere like in your javascript, is that right? 


Please help me, thanks in advice

0 Votes

S

Stanley Bucasas posted about 8 years ago

Has there been any movement on this feature?  THIS WOULD BE HUGE for me.  Im using FPD for a large scale product, 68 inches high by 11 inches wide in some cases.  Combined with having to scale sizes up in the end to have the proper resolution, being able to just export the bounding box will make final filesizes a little smaller,and easier to produce at the end.

0 Votes

T

Tim Hurrell posted about 8 years ago

What would also be good would be for the image export of the bounding box to be e-mailed to the store owner along with the order. That way we can wait for a order to come in, send the png or pdf straight to print and apply it to the garment.

0 Votes

S

Stanley Bucasas posted about 8 years ago

I agree. The least amount of work on the backend is key for my client. An global export setting or something in the settings that once you set it, every order is automatically exported at the right size, file type, and sent to your email.

0 Votes

S

Stanley Bucasas posted about 8 years ago

For now, I was able to remove the actions buttons outside the stage and set the stage size to the exact size of my banners.  This has helped tremendously by keeping the file sizes down since im scaling them up so big.



0 Votes

C

Cacl ontrui posted almost 8 years ago

Wow, i plan to buy the FPD but this will definitely keep me holding it off.

Such a great suggestion and the author seems doesn't care about. His purpose is to create a Fancy plugin without practical sense as one of the comments said.

Thanks everyone for their comments which keeps me wasting my time to test this plugin.

0 Votes

D

Daniel Farkas posted over 7 years ago

"
  • create a "NO EXPORT" flag in the Product Builders Layers, and respect that flag when exporting the final image
  • Export only whats inside of the bounding box, clipping out the rest of the STAGE. For printing production we need a good hires image
  • Create a "Save as default settings" in the export options, so that you don't have to type the DPI and the scale factor FOR EVERY ORDER :( "

    I need these features too. Please, upgrade the export functions! Thank you very much!

0 Votes

N

Nate posted over 7 years ago

Confirmed that the fix does not work in WP 4.7 with WooCommerce. Does the plugin developer look at these message boards often? This should be top priority on an upcoming development sprint.

0 Votes

D

David Fozdar posted over 7 years ago

This plugin does suffer from some serious issues, and, unfortunately, the developers appear to rarely address issues on the forums.

You really have to engineer things in order to get this plugin to work. Because of the lack of progress in development, I am starting to look elsewhere to be honest.

0 Votes

S

Stanley Bucasas posted over 7 years ago

The plugin is $50.  Though I got lucky with my solution because my final graphic is always a perfect rectangle, good luck finding something else in that price range.

0 Votes

D

David Fozdar posted over 7 years ago

Indeed, it's a great plugin. However, the idea of exporting the bounding box only makes sense, even if the plugin is only $50.

We've also mentioned in numerous posts (as customers/users) that the developer should/would have to increase prices if things like enhanced PDF handling and such are added. Thus, nobody is advocating that the developer should continue to charge only $50 if improvements continue to be made. However, many of the show-stopping issues that the developer has planned to address have not been addressed over the last year or so. Though we understand that things take time to accomplish, we would also liked to be informed on the progress the developer is making. We, as customers, also have businesses to run where time is money. If things cannot be accomplished, then we have to look elsewhere, albeit it costs us more money.


 

0 Votes

J

Joao Figueiredo posted over 7 years ago

Stanley, please do your homework! Read the threads in the forum! Most of us - if not all of us - are willing to pay more for that function!

 

0 Votes

Rafael D

Rafael D posted over 7 years ago Admin

We have been working on a new solution the last months, that will move Fancy Product Designer forward. I am going to release a beta the next days and some of you have the opportunity to test it. 


Sorry for the delay.....but all of these highly discussed threads will be addresses in the new solution.

0 Votes

J

Joao Figueiredo posted over 7 years ago

Thumbs up Radykal! I Cannot say how much I am looking forward for it! My company has been holding up a big investment waiting for this update. It will be mostly welcome, $ 50 or more!

Keep up the really good work and keep us updated! :)

0 Votes

D

David Fozdar posted over 7 years ago

+1 (thumbs up) to what Joao said. I am also really looking forward to it. We all appreciate the hard work Radykal. Let us know if you need help.

Like I said, I was just implying that it would be nice to get more frequent updates on progress.




 

0 Votes