Pptxgenjs: Flip vertical and horizontal not working as expected for images

Created on 14 Jul 2020  路  3Comments  路  Source: gitbrent/PptxGenJS

Category

  • [ ] Enhancement
  • [x] Bug
  • [ ] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: [3.1.1]

Please specify what version(s) of PowerPoint you are targeting: [PowerPoint for Mac 16.38]

Expected / Desired Behavior / Question

Applying flipV and flipH would flip the generated image elements vertically or horizontally.

Observed Behavior

Image stays the same as if no property was added. It works as expected for Text, only images have this problem.

Steps to Reproduce

Use the properties flipV = true or flipH = true in an image object

bug

Most helpful comment

This should be a pretty straight forward fix.

in gen-objects.ts need to update this:

    // STEP 3: Set image properties & options
    // FIXME: Measure actual image when no intWidth/intHeight params passed
    // ....: This is an async process: we need to make getSizeFromImage use callback, then set H/W...
    // if ( !intWidth || !intHeight ) { var imgObj = getSizeFromImage(strImagePath);
    newObject.options = {
        x: intPosX || 0,
        y: intPosY || 0,
        w: intWidth || 1,
        h: intHeight || 1,
        rounding: typeof opt.rounding === 'boolean' ? opt.rounding : false,
        sizing: sizing,
        placeholder: opt.placeholder,
        rotate: opt.rotate || 0,
    }

to

    // STEP 3: Set image properties & options
    // FIXME: Measure actual image when no intWidth/intHeight params passed
    // ....: This is an async process: we need to make getSizeFromImage use callback, then set H/W...
    // if ( !intWidth || !intHeight ) { var imgObj = getSizeFromImage(strImagePath);
    newObject.options = {
        x: intPosX || 0,
        y: intPosY || 0,
        w: intWidth || 1,
        h: intHeight || 1,
        rounding: typeof opt.rounding === 'boolean' ? opt.rounding : false,
        sizing: sizing,
        placeholder: opt.placeholder,
        rotate: opt.rotate || 0,
                 flipV: opt.flipV || false,
                 flipH: opt.flipH || false,
    }

All 3 comments

This should be a pretty straight forward fix.

in gen-objects.ts need to update this:

    // STEP 3: Set image properties & options
    // FIXME: Measure actual image when no intWidth/intHeight params passed
    // ....: This is an async process: we need to make getSizeFromImage use callback, then set H/W...
    // if ( !intWidth || !intHeight ) { var imgObj = getSizeFromImage(strImagePath);
    newObject.options = {
        x: intPosX || 0,
        y: intPosY || 0,
        w: intWidth || 1,
        h: intHeight || 1,
        rounding: typeof opt.rounding === 'boolean' ? opt.rounding : false,
        sizing: sizing,
        placeholder: opt.placeholder,
        rotate: opt.rotate || 0,
    }

to

    // STEP 3: Set image properties & options
    // FIXME: Measure actual image when no intWidth/intHeight params passed
    // ....: This is an async process: we need to make getSizeFromImage use callback, then set H/W...
    // if ( !intWidth || !intHeight ) { var imgObj = getSizeFromImage(strImagePath);
    newObject.options = {
        x: intPosX || 0,
        y: intPosY || 0,
        w: intWidth || 1,
        h: intHeight || 1,
        rounding: typeof opt.rounding === 'boolean' ? opt.rounding : false,
        sizing: sizing,
        placeholder: opt.placeholder,
        rotate: opt.rotate || 0,
                 flipV: opt.flipV || false,
                 flipH: opt.flipH || false,
    }

Just opened a PR for this, #824

Thanks @luism-s - it's slated for the 3.4.0 release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alexiz-Padilla picture Alexiz-Padilla  路  5Comments

cwilkens picture cwilkens  路  6Comments

bestis picture bestis  路  6Comments

Slidemagic picture Slidemagic  路  4Comments

LeoFC97 picture LeoFC97  路  3Comments