diff --git a/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m b/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m index 3ad617fd31..8c0ddae431 100644 --- a/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m +++ b/submodules/LegacyComponents/Sources/TGMediaVideoConverter.m @@ -350,6 +350,10 @@ if (TGOrientationIsSideward(adjustments.cropOrientation, NULL)) outputDimensions = CGSizeMake(outputDimensions.height, outputDimensions.width); + + if ((preset == TGMediaVideoConversionPresetProfile || preset == TGMediaVideoConversionPresetProfileHigh || preset == TGMediaVideoConversionPresetProfileVeryHigh) && MIN(outputDimensions.width, outputDimensions.height) < 160.0) { + outputDimensions = CGSizeMake(160.0, 160.0); + } AVMutableCompositionTrack *compositionTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; [compositionTrack insertTimeRange:timeRange ofTrack:videoTrack atTime:kCMTimeZero error:NULL]; diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index 2a3f5209b4..3e719ef8a3 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -328,7 +328,7 @@ _previewView.clipsToBounds = true; [_previewView setSnapshotImage:_screenImage]; [_photoEditor setPreviewOutput:_previewView]; - [self updatePreviewView]; + [self updatePreviewView:true]; if ([self presentedForAvatarCreation]) { CGSize fittedSize = TGScaleToSize(_photoEditor.originalSize, CGSizeMake(1024, 1024)); @@ -1267,6 +1267,8 @@ strongSelf->_dotImageView.cropOrientation = strongSelf->_photoEditor.cropOrientation; strongSelf->_dotImageView.cropMirrored = strongSelf->_photoEditor.cropMirrored; [strongSelf->_dotImageView updateCropping:true]; + + [strongSelf updatePreviewView:false]; } }; cropController.beginTransitionIn = ^UIView *(CGRect *referenceFrame, UIView **parentView, bool *noTransitionView) @@ -1584,7 +1586,7 @@ { __strong TGPhotoEditorController *strongSelf = weakSelf; if (strongSelf != nil) - [strongSelf updatePreviewView]; + [strongSelf updatePreviewView:true]; }; _currentTabController.tabsChanged = ^ { @@ -1610,10 +1612,16 @@ [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; } -- (void)updatePreviewView +- (void)updatePreviewView:(bool)full { - [_previewView setPaintingImageWithData:_photoEditor.paintingData]; - [_previewView setCropRect:_photoEditor.cropRect cropOrientation:_photoEditor.cropOrientation cropRotation:_photoEditor.cropRotation cropMirrored:_photoEditor.cropMirrored originalSize:_photoEditor.originalSize]; + if (full) + [_previewView setPaintingImageWithData:_photoEditor.paintingData]; + + UIImageOrientation cropOrientation = _photoEditor.cropOrientation; + if ([self presentedForAvatarCreation]) { + cropOrientation = UIImageOrientationUp; + } + [_previewView setCropRect:_photoEditor.cropRect cropOrientation:cropOrientation cropRotation:_photoEditor.cropRotation cropMirrored:_photoEditor.cropMirrored originalSize:_photoEditor.originalSize]; } - (void)updateEditorButtons @@ -1823,6 +1831,9 @@ if (paintingData != nil) [TGPaintingData storePaintingData:paintingData inContext:self.editingContext forItem:_item forVideo:(_intent == TGPhotoEditorControllerVideoIntent)]; + + [_previewView setPaintingImageWithData:_photoEditor.paintingData]; + [_previewView setPaintingHidden:false]; } - (void)applyEditor diff --git a/submodules/LegacyComponents/Sources/TGPhotoPaintController.m b/submodules/LegacyComponents/Sources/TGPhotoPaintController.m index e1571159df..28451e9def 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoPaintController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoPaintController.m @@ -117,7 +117,6 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f; TGMenuContainerView *_menuContainerView; TGPaintingData *_resultData; - UIImage *_stillImage; TGPaintingWrapperView *_paintingWrapperView; diff --git a/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m b/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m index 98be115651..0c26bf2a6e 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m +++ b/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m @@ -26,7 +26,7 @@ arc4random_buf(&fileId, sizeof(fileId)); NSString *videoMp4FilePath = [tmpPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%" PRId64 ".mp4", fileId]]; [[NSFileManager defaultManager] removeItemAtPath:videoMp4FilePath error:nil]; - [[NSFileManager defaultManager] createSymbolicLinkAtPath:videoMp4FilePath withDestinationPath:video.path error:nil]; + [[NSFileManager defaultManager] copyItemAtPath:video.path toPath:videoMp4FilePath error:nil]; video = [NSURL fileURLWithPath:videoMp4FilePath]; }