Edit

Example of scaling icons and labels.

Icons and labels can be scaled in both dimensions if required. A negative value will flip the image or text around its anchor point (reversed text is not suitable for line placement). A newline character inserted in label text is interpreted in a vector layer, but will not be shown in a vector context.

main.js
import 'ol/ol.css';
import Feature from 'ol/Feature';
import Map from 'ol/Map';
import Overlay from 'ol/Overlay';
import Point from 'ol/geom/Point';
import TileJSON from 'ol/source/TileJSON';
import VectorSource from 'ol/source/Vector';
import View from 'ol/View';
import {Icon, Style, Text} from 'ol/style';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
import {fromLonLat} from 'ol/proj';
import {getVectorContext} from 'ol/render';

var rasterLayer = new TileLayer({
  source: new TileJSON({
    url: 'https://a.tiles.mapbox.com/v3/aj.1x1-degrees.json?secure=1',
    crossOrigin: '',
  }),
});

var iconFeature = new Feature({
  geometry: new Point(fromLonLat([0, -10])),
  name: 'Fish.1',
});

var feature1 = new Feature({
  geometry: new Point(fromLonLat([0, -10])),
  name: 'Fish.1 Island',
});

var feature2 = new Feature({
  geometry: new Point(fromLonLat([-30, 10])),
  name: 'Fish.2 Island',
});

var iconStyle = new Style({
  image: new Icon({
    anchor: [0.5, 0.9],
    src: 'data/fish.png',
    crossOrigin: '',
    scale: [0, 0],
    rotation: Math.PI / 4,
  }),
  text: new Text({
    text: 'FISH\nTEXT',
    scale: [0, 0],
    rotation: Math.PI / 4,
    textAlign: 'center',
    textBaseline: 'top',
  }),
});

var i = 0;
var j = 45;

iconFeature.setStyle(function () {
  var x = Math.sin((i * Math.PI) / 180) * 3;
  var y = Math.sin((j * Math.PI) / 180) * 4;
  iconStyle.getImage().setScale([x, y]);
  iconStyle.getText().setScale([x, y]);
  return iconStyle;
});

rasterLayer.on('postrender', function (event) {
  var vectorContext = getVectorContext(event);
  var x = Math.cos((i * Math.PI) / 180) * 3;
  var y = Math.cos((j * Math.PI) / 180) * 4;
  iconStyle.getImage().setScale([x, y]);
  iconStyle.getText().setScale([x, y]);
  vectorContext.drawFeature(feature2, iconStyle);
});

var vectorSource = new VectorSource({
  features: [iconFeature, feature1, feature2],
});

var vectorLayer = new VectorLayer({
  source: vectorSource,
});

var map = new Map({
  layers: [rasterLayer, vectorLayer],
  target: document.getElementById('map'),
  view: new View({
    center: fromLonLat([-15, 0]),
    zoom: 3,
  }),
});

setInterval(function () {
  i = (i + 4) % 360;
  j = (j + 5) % 360;
  vectorSource.changed();
}, 1000);

var element = document.getElementById('popup');

var popup = new Overlay({
  element: element,
  positioning: 'bottom-center',
  stopEvent: false,
  offset: [0, -50],
});
map.addOverlay(popup);

// display popup on click
map.on('click', function (evt) {
  var feature = map.forEachFeatureAtPixel(evt.pixel, function (feature) {
    return feature;
  });
  $(element).popover('dispose');
  if (feature) {
    var coordinates = feature.getGeometry().getCoordinates();
    popup.setPosition(coordinates);
    $(element).popover({
      placement: 'top',
      html: true,
      animation: false,
      content: feature.get('name'),
    });
    $(element).popover('show');
  }
});

// change mouse cursor when over marker
map.on('pointermove', function (e) {
  if (e.dragging) {
    $(element).popover('dispose');
    return;
  }
  var pixel = map.getEventPixel(e.originalEvent);
  var hit = map.hasFeatureAtPixel(pixel);
  map.getTarget().style.cursor = hit ? 'pointer' : '';
});
index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Icon Scale</title>
    <!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
    <script src="https://unpkg.com/elm-pep"></script>
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL,TextDecoder"></script>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js"></script>
    <style>
      .map {
        width: 100%;
        height:400px;
      }
    </style>
  </head>
  <body>
    <div id="map" class="map"><div id="popup"></div></div>
    <script src="main.js"></script>
  </body>
</html>
package.json
{
  "name": "icon-scale",
  "dependencies": {
    "ol": "6.5.0"
  },
  "devDependencies": {
    "parcel": "^2.0.0-beta.1"
  },
  "scripts": {
    "start": "parcel index.html",
    "build": "parcel build --public-url . index.html"
  }
}