4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pixasticで複数のアクションを同時に実行するためのTips

Posted at

ブラウザ上で画像を編集するため、Pixasticというライブラリを利用している。

ひとつひとつのアクションを実行するのは問題ないが、複数のアクションを実行するとたまに反映されない事がある。

Pixastic.process(
  img,
  'brightness',
  {brightness: param.brightness, contrast: param.contrast / 100}
);

Pixastic.process(
  img,
  'rotate',
  {angle: param.angle
);

解決策としては、processのコールバックで次のアクションを実行することで、正しく反映されるようになる。

Pixastic.process(
  img,
  'brightness',
  {brightness: param.brightness, contrast: param.contrast / 100},
  function(res) {
    Pixastic.process(
      res,
      'rotate',
      {angle: param.angle
    );
  }
);

※processの戻り値を第一引数に指定することも考えたが、dataImg.completeがfalseになりundefinedになるため断念

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?