Ответ был довольно простым
Ссылка: https://code -industry.net / masterpdfeditor-help / преобразование-матрица /
private void calculateCoordinates(final ImageFile imageFile, final Matrix ctmNew) {
double llx = calculateXCoordinate(ctmNew, 0, 0);
double lly = calculateYCoordinate(ctmNew, 0, 0);
double ulx = calculateXCoordinate(ctmNew, 0, 1);
double uly = calculateYCoordinate(ctmNew, 0, 1);
double lrx = calculateXCoordinate(ctmNew, 1, 0);
double lry = calculateYCoordinate(ctmNew, 1, 0);
double urx = calculateXCoordinate(ctmNew, 1, 1);
double ury = calculateYCoordinate(ctmNew, 1, 1);
final double left = Math.min(Math.min(llx, ulx), Math.min(lrx, urx));
final double top = Math.max(Math.max(lly, uly), Math.max(lry, ury));
final double right = Math.max(Math.max(llx, ulx), Math.max(lrx, urx));
final double bottom = Math.min(Math.min(lly, uly), Math.min(lry, ury));
imageFile.setTop(top);
imageFile.setBottom(bottom);
imageFile.setLeft(left);
imageFile.setRight(right);
}
private double calculateXCoordinate(final Matrix ctmNew, final double x, final double y) {
double a = ctmNew.getValue(0, 0);
double c = ctmNew.getValue(1, 0);
double e = ctmNew.getValue(2, 0);
return a * x + c * y + e;
}
private double calculateYCoordinate(final Matrix ctmNew, final double x, final double y) {
double b = ctmNew.getValue(0, 1);
double d = ctmNew.getValue(1, 1);
double f = ctmNew.getValue(2, 1);
return b * x + d * y + f;
}